Template function specialization doesn't work
nise at nise.com
Tue Jul 7 19:53:30 UTC 2020
I have two template functions
void overloadedFunction(T)(ref T val)
void overloadedFunction(T : T)(ref T s)
Obviously the second should be used when the parameter is a slice
of any type, and the first should be used in other cases. However
this doesn't happen, the compiler always picks the first function
regardless if the parameter is a slice or not.
ubyte ar = [ 1, 2, 3 ];
ubyte arSlice = ar;
The first function will be used. Shouldn't the template argument
(T : T) make the compiler pick the second one?
More information about the Digitalmars-d-learn