How to test templates for equality?
Philippe Sigaud via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jul 6 12:10:52 PDT 2014
Seeing his example, the OP wants a solution that works even for templates:
template Test1(T) {}
pragma(msg, instanceArgsOf!(Test1, Test1!int));
which fails because Test1!int is not a type (std.traits.isInstanceOf
fails also, for the same reason).
And is(symbol == Name!Args, Args...) does not work if Name!Args and
symbol are not types.
In this particular case, the only solution I know of is an awful hack:
using .stringof and __traits(identifier, x) and then parse the
strings:
"Name!(int, double[string])" and "Name(T, U[V], U, V)"
and then the fun begins: in the general case, you must then equate the
arguments lists (recursively).
Philippe
More information about the Digitalmars-d-learn
mailing list