Two function templates with the same name can coexist, even though they may be instantiated so that both have identical parameter types.
1 #include <iostream>
2 using namespace std;
3
4 template<typename T>
5 int f(T)
6 {
7 return 1;
8 }
9
10 template<typename T>
11 int f(T*)
12 {
13 return 2;
14 }
15
16 int _tmain(int argc, _TCHAR* argv[])
17 {
18 cout << f<int*>((int*)0) << endl;
19 cout << f<int>((int*)0) << endl;
20
21 cin.get();
22 return 0;
23 }
Function signature:
-
The unqualified name of the function (or the name of the function template from which it was generated)
-
The class or namespace scope of that name and, if the name has internal linkage, the translation unit in which the name is declared
-
The const, volatile, or const volatile qualification of the function (if it is a member function with such a qualifier)
-
The types of the function parameters (before template parameters are substituted if the function is generated from a function template)
-
Its return type, if the function is generated from a function template
-
The template parameters and the template arguments, if the function is generated from a function template