loop through specific class members

BCS none at anon.com
Mon Jan 26 20:35:29 PST 2009


Hello Sergey,

> but this doesn't:
> 
> template Tuple(T...)
> {
> alias T Tuple;
> }
> void foo()
> {
> foreach (a; Tuple!("a", "b", "c"))
> pragma(msg, a);
> }
> $ dmd -c test.d
> test.d(8): Error: string expected for message, not 'a'
> test.d(8): Error: string expected for message, not 'a'
> test.d(8): Error: string expected for message, not 'a'
> *This* seems like a bug to me.
> 

try indexing it:

template Tuple(T...)
{
 alias T Tuple;
}
void foo()
{
 alias Tuple!("a", "b", "c") Tpl;
 foreach (i,a; Tpl)
  pragma(msg, Tpl[i]);
}

(BTW that is a known bug)




More information about the Digitalmars-d-learn mailing list