digitalmars.D - Is this supposed to be a bug?
- Daniel Ribeiro Maciel (19/19) Nov 02 2008 void handler( alias dg )()
- Jarrett Billingsley (5/24) Nov 02 2008 For some reason you can't use 'ref' on tuple foreaches. You'll just
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
Nov 02 2008
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, DanielFor 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 */ }
Nov 02 2008