November 03, 2008 Is this supposed to be a bug? | ||||
|---|---|---|---|---|
| ||||
void handler( alias dg )()
{
alias ParameterTypeTuple!( typeof(dg) ) TParamTuple;
alias ReturnType!(dg) TResult;
TParamTuple params;
foreach( ref param; params )
{}
}
double hello( double i )
{
writefln( "zomfg ", i );
}
int main( in string[] )
{
handler!(hello)();
}
This code yields error on "foreach( ref param; params )": Error : No storage class for value param
Best regards,
Daniel
| ||||
November 03, 2008 Re: Is this supposed to be a bug? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Daniel Ribeiro Maciel | On Sun, Nov 2, 2008 at 7:56 PM, Daniel Ribeiro Maciel <daniel.maciel@gmail.com> wrote:
> void handler( alias dg )()
> {
> alias ParameterTypeTuple!( typeof(dg) ) TParamTuple;
> alias ReturnType!(dg) TResult;
>
> TParamTuple params;
> foreach( ref param; params )
> {}
> }
>
> double hello( double i )
> {
> writefln( "zomfg ", i );
> }
>
> int main( in string[] )
> {
> handler!(hello)();
> }
>
> This code yields error on "foreach( ref param; params )": Error : No storage class for value param
>
> Best regards,
> Daniel
>
>
For some reason you can't use 'ref' on tuple foreaches. You'll just have to use the index-value version:
foreach(i, param; params) { /* set params[i] here */ }
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply