Enum to string array
Don
nospam at nospam.com.au
Wed Oct 1 06:01:16 PDT 2008
bearophile wrote:
> Spacen Jasset:
>> enum Symbols {
>> CYCLIC_FORWARD, CYCLIC_BACKWARD, CYCLIC_LEFT, etc
>> };
>> How could I map this into an array? (or vice-versa) must I use a switch
>> statement, or an enum -> string mapping array?
>
> You can create a template mixin that given the list of names as strings, defines an enum and its array of strings, to map index => symbol.
Such a thing already exists in phobos2 in std.typecons.
More information about the Digitalmars-d-learn
mailing list