Get name of enum val at compile-time?

Peter Alexander at
Sun Jan 15 14:43:09 PST 2012

On 15/01/12 10:29 PM, Philippe Sigaud wrote:
> On Sun, Jan 15, 2012 at 22:19, Timon Gehr<timon.gehr at>  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, 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?");
>      }
> }

The compiler should be able to give you a better error message. It 
shouldn't be the responsibility of the programmer to provide sensible 
error messages when you call a function with the wrong number of arguments.

More information about the Digitalmars-d-learn mailing list