Printing type name in static assert
Dicebot
public at dicebot.lv
Sat Jan 25 03:44:03 PST 2014
On Saturday, 25 January 2014 at 11:28:40 UTC, Martin Cejp wrote:
> I'm trying to do something to this effect:
>
> template XYZ(Class) {
> ...
> static assert(index != -1, "No such annotation on " ~
> typeid(Class));
> ...
> }
>
> However, typeid is not a string and I can't do to!string. Nor
> is typeid().name implemented at compile time.
> What would be the correct way to do this?
for just printing `Class.stringof` is most simple thing to do.
There are also `__traits(identifier, Class)` and
`std.traits.fullyQualifiedName!Class` that are more specialized
and usually used in code generation.
More information about the Digitalmars-d
mailing list