Identify enum

BCS ao at pathlink.com
Mon Jul 21 11:23:36 PDT 2008


Reply to Moritz,

> I have a global toString template function that is also used for
> various
> enums.
> If the toString is used for an unknown Type it's supposed to print out
> an error message at compile time (static assert).
> Now I face the problem that toString is used for some enum I haven't
> modified toString for, but I can't identify the the enums name.
> All I get is the base type int, which is pretty useless.
> I can search my entire codebase and make a list of all enum types it
> is used for. But that's pretty hard for some big templates engines.
> 
> Is there a workaround?
> 

A little more info might be useful.

As a starting point I'll assume the toString is something like this:

char[] toString(T)(T arg)...
{

static if(is(T == type1)) {something}
else static if(is(T type2)) {something}
...
else static assert(false,"can't use "~T.stringof);

}

and that the assert is giving something useless.

Is that the case or are you taking a different approach?





More information about the Digitalmars-d-learn mailing list