So I have this template function which takes two parameters. The parameters can have two different types, but I want the function to behave differently if both types are the same.
It makes sense to me that the compiler would prefer to use B whenever possible, and will use A only if the types are different (which means B can't be used).
did u already try it out?... what are your results?...
in my opinion this would make sence especially in terms of compiling performance... but im not someone to rely on when concering performance, sorry^...
To be standard conform, the compiler must prefer B to A if both template arguments are of equal type.
B is "more specialized" than A, because you can instantiate A with deduced parameters from B (A::func<T,T> is valid), but not vice versa (B::func<T,U> is not valid - T and U are unique types in the test). Compiler have to choose the "most specialized" function.