On Friday, 30 March 2018 at 15:49:30 UTC, jmh530 wrote:
On Friday, 30 March 2018 at 15:21:26 UTC, jmh530 wrote:
[snip]
Doesn't extend to multiple template parameters that well...
import std.traits : TemplateOf;
struct TestType(T, U) {}
alias TestAlias(T) = TestType!(T, int);
template testFunction(T, alias U = TemplateOf!(TestAlias!T))
What you're showing here is a somewhat different case. First,
you're telling TestAlias to turn into a TestType. Then you ask
which template that type is an instance of. That's going to be
TestType, every single time. And it being anything else would be
a source of great confusion:
auto a = TestType!(string, int)();
auto b = TestAlias!string();
// We expect this to be true:
assert(is(typeof(a) == typeof(b)));
// And I'll be damned if this ain't:
assert(__traits(isSame, TemplateOf!(typeof(a)),
TemplateOf!(typeof(b))));
--
Simen