On Thursday, 23 February 2017 at 16:01:44 UTC, John Colvin wrote:
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)`
I don't believe so, because foo(3) is a value (void), not a type
like foo!int would be. You can't get it back after you've called
the function. You would have to do something like:
alias fooWithInt = someMagic!foo(3);
Where someMagic constructs the alias to foo!int based on the type
of arguments passed, or something like that.