template parameter inference and introspection

John Colvin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Feb 23 08:01:44 PST 2017


Is there any way to get a reference/alias to the instantiation of 
a template function that would be called, given certain 
parameters? I.e. to get the result of whatever template parameter 
inference (and overload resolution) has occurred?

E.g. for some arbitrarily complex foo:

static assert(__traits(compiles, foo(3)));
alias fooWithInt = someMagic(foo(3));

so if foo was `void foo(T)(T t) {}` then `fooWithInt` would be 
`foo!int`, but if it was `void foo(Q = float, T = long)(T t)` 
then `fooWithInt` would be `foo!(float, int)`


More information about the Digitalmars-d-learn mailing list