Get name of enum val at compile-time?

Philippe Sigaud philippe.sigaud at gmail.com
Sun Jan 15 14:29:51 PST 2012


On Sun, Jan 15, 2012 at 22:19, Timon Gehr <timon.gehr at gmx.ch> wrote:

Nick:
>> Goddamnnit, what the fuck is wrong with me? Yes that works :)
>
> I suspect a better error message would have prevented this.
> DMD still has some potential of improvement in that area. =)

In that case, to!(Origin, Target) could be extended to deal with
to!(Origin, <empty there>).
It's been a long time since I last looked at std.conv.to, but maybe:

template to(T)
{
    T to(A...)(A args)
    {
        static if (A.length)
            return toImpl!T(args);
        else
            static assert(false, "Trying to use to!("~T.stringof~")
with no argument. What were you trying to do?");
    }
}


More information about the Digitalmars-d-learn mailing list