getting Key:Value pairs of an enum at compile time ?
Uplink_Coder
someemail at someprovider.some
Thu Jan 23 09:55:50 PST 2014
> Could you show an exact code that fails?
sure!
auto EnumToSelect(Enum)(string Name = __traits(identifier,Enum))
if (is(Enum==enum)) {
foreach (i,Item;[__traits(allMembers,Enum)]) {
else
form_string ~= "\toption(value='"~Item~"')
"~__traits(getMember,Enum,Item)~"\n";
}
debug import std.stdio;
debug writeln(form_string);
return form_string;
}
More information about the Digitalmars-d-learn
mailing list