getting Key:Value pairs of an enum at compile time ?

Stanislav Blinov stanislav.blinov at gmail.com
Thu Jan 23 08:26:27 PST 2014


On Thursday, 23 January 2014 at 15:31:53 UTC, Uplink_Coder wrote:
>> Try getMember: http://dlang.org/traits.html#getMember
> if i try it, I get __aggr2297 cannot be read at compile time

There's a convenience wrapper for that, EnumMembers:

http://dlang.org/phobos/std_traits.html#.EnumMembers

void main() {
     foreach(m; EnumMembers!Options) {
         writeln(m, " ", cast(string)m);
     }
}


More information about the Digitalmars-d-learn mailing list