Improving std.typecons.defineEnum

Tomek Sowiński just at ask.me
Wed Oct 6 13:54:48 PDT 2010


Andrei Alexandrescu napisał:

> That's a good contribution, but I just deprecated enumToString in a
> recent commit because D's current introspection abilities made it easy
> to define parse and to!string to manipulate enum names.
> 
> I'll be looking forward to other goodies!

Thanks, I just saw std.conv -- looks much better.

BTW, instead of:

foreach (i, e; EnumMembers!Target)
{
    auto ident = __traits(allMembers, Target)[i];
    if (s.skipOver(ident))
        return e;
}

you can:

foreach (ident; __traits(allMembers, Target))
    if (s.skipOver(ident))
        return __traits(getMember, Target, ident);


But that's nitpicking :)

-- 
Tomek


More information about the Digitalmars-d mailing list