Comment #0 by andrej.mitrovich — 2012-02-29T03:08:58Z
import std.stdio;
struct Base(bool T)
{
static if (T)
{
int x;
}
int y;
}
void main()
{
alias Base!false Type;
auto fields = [__traits(allMembers, Type)];
writeln(fields); // writes ["x", "y"]
}
"x" does not exist in the Base!false instance.
Comment #1 by andrej.mitrovich — 2012-02-29T03:12:24Z
Actually
Comment #2 by andrej.mitrovich — 2012-02-29T03:13:06Z
Actually it's broken for non-template types too:
import std.stdio;
import std.traits;
struct Base
{
version(none)
{
int x;
}
int y;
}
void main()
{
auto vals = [__traits(allMembers, Base)];
writeln(vals); // writes ["x", "y"]
}