Forcing static foreach

Robert Clipsham robert at octarineparrot.com
Tue Apr 24 07:34:17 PDT 2012


Is there anyway to force a static foreach to occur?
----
template TT(T...)
{
     alias T TT;
}
void main()
{
     // This works
     foreach(s; TT!("a", "b", "c"))
     {
         mixin(`int ` ~ s ~ `;`);
     }

     enum foo = TT!("a", "b", "c");
     // This fails
     foreach(s; foo)
     {
         mixin(`int ` ~ s ~ `;`);
     }
}
----

Thanks,

-- 
Robert
http://octarineparrot.com/


More information about the Digitalmars-d-learn mailing list