Comment #0 by dlang-bugzilla — 2014-03-16T22:37:26Z
//////// test.d ////////
alias X(T) = T;
void f(T)(T a, X!T b) {}
void main()
{
f(5, 5);
}
////////////////////////
Once the compiler knows what type T is, it can also know what X!T is.
Comment #1 by dlang-bugzilla — 2014-03-16T22:50:51Z
This doesn't work as one might expect:
void f(T, U=X!T)(T a, U b) {}
U will always be inferred from the type of b, overriding the default.
Valid workaround:
void f(T, U)(T a, U b) if(is(U==X!T)) {}
Comment #2 by dlang-bugzilla — 2014-03-17T00:06:58Z
The above workaround doesn't work for certain cases:
alias X(T) = T;
void f(T, U)(T a, U b) if(is(U : X!T)) { }
void main()
{
ubyte b = 5;
f(b, 5);
}
Comment #3 by hsteoh — 2014-09-25T20:25:33Z
Related: issue #10228
Comment #4 by robert.schadek — 2024-12-13T18:18:25Z