Printing type name in static assert

Martin Cejp minexew at gmail.com
Sat Jan 25 03:46:55 PST 2014


On Saturday, 25 January 2014 at 11:44:04 UTC, Dicebot wrote:
> 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.

Thanks, that will do.
fullyQualifiedName was the first that came to mind, but it's 
broken.


More information about the Digitalmars-d mailing list