Enum literals, good? bad? what do you think?

Walter Bright newshound2 at digitalmars.com
Wed Jul 21 20:47:19 UTC 2021


On 7/21/2021 12:11 AM, Patrick Schluter wrote:
>> `alias` is an all-purpose tool for moving names from one scope to another. Of 
>> course, one can probably do a mixin to automate the alias declarations. It 
>> should be a fun exercise. Any takers?
> 
> mixin({
>    auto aliasList = "";
>    static foreach(m; __traits(allMembers, MyEnum))
>      aliasList ~= "alias "~m~" = MyEnum."~m~";\n"
>    return aliasList;
> }());

Sweet!

Please put in the D wiki somewhere!


More information about the Digitalmars-d mailing list