Valid function-template overloading
suggest changeA function template can be overloaded when its signature differs from another
template with the same name. A function-template signature includes its
parameter types, return type, template-head, enclosing namespace, and trailing
requires clause. For example, templates can differ in either of these ways:
- Their parameter or return types differ.
- Their template parameter lists or constraints differ. Parameter names and default template arguments do not distinguish signatures.
Dependent expressions in a signature are compared using template-equivalence rules rather than by trying every possible substitution. Renaming corresponding template parameters does not make declarations different. If two expressions are spelled differently but produce the same result for every possible set of template arguments, they are functionally equivalent. A program whose meaning depends on treating functionally equivalent but non-equivalent declarations as different is ill-formed; no diagnostic is required.
template<typename T>
void f(T*) { }
template<typename T>
void f(T) { }
This is a valid overload because T and T* are different parameter types.
The following declarations are functionally equivalent but not equivalent, so
the program is ill-formed with no diagnostic required:
template<typename T>
void f(T (*x)[sizeof(T) + sizeof(T)]) { }
template<typename T>
void f(T (*x)[2 * sizeof(T)]) { }