You may overload a function template either by a non-template function or by another function template.
#include <iostream>
using namespace std;
template<class T> void f(T x, T y) { cout << "Template" << endl; }
void f(int w, int z) { cout << "Non-template" << endl; }
int main() {
f( 1 , 2 );
f('a', 'b');
f( 1 , 'b');
}
The following is the output of the above example: Non-template Template Non-templateThe function call f(1, 2) could match the argument types of both the template function and the non-template function. The non-template function is called because a non-template function takes precedence in overload resolution.
The function call f('a', 'b') can only match the argument types of the template function. The template function is called.
Argument deduction fails for the function call f(1, 'b'); the compiler does not generate any template function specialization and overload resolution does not take place. The non-template function resolves this function call after using the standard conversion from char to int for the function argument 'b'.