digitalmars.D.learn - Forcing static foreach
- Robert Clipsham (25/25) Apr 24 2012 Is there anyway to force a static foreach to occur?
- David (3/4) Apr 24 2012 alias TT!("a", "b", "c") foo;
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/
Apr 24 2012
Am 24.04.2012 16:34, schrieb Robert Clipsham:
enum foo = TT!("a", "b", "c");
alias TT!("a", "b", "c") foo;
btw. there is std.typecons : TypeTuple with helpers (like staticMap)
Apr 24 2012








David <d dav1d.de>