This implementation matches GCC behavior in that temp.func.order p6.2.1 is not implemented . I reached out to the GCC author to confirm that some changes elsewhere to overload resolution are probably needed, but no solution has been developed sufficiently .
Most of the wordings are implemented straightforwardly. However,
for temp.func.order p6.2.2 "... or if the function parameters that positionally correspond between the two templates are not of the same type", the "same type" is not very clear ( is a bug related to this). Here is a quick example
template <C T, C U> int f(T, U); template <typename T, C U> int f(U, T); int x = f(0, 0);
Is the U and T from different fs the "same type"? The answer is NO even though both U and T are deduced to be int in this case. The reason is that U and T are dependent types, according to temp.over.link p3, they can not be the "same type".
To check if two function parameters are the "same type":
- For function template: compare the function parameter canonical types and return type between two function templates.
- For class template/partial specialization: by temp.spec.partial.order p1.2, compare the injected template arguments between two templates using hashing(TemplateArgument::Profile) is enough.