If I compile and run the above program, function b) is called. For some reason, the compiler is treating function c) as a specialisation of a) and not as a specialisation of b).
using namespace std;
template <class T> void f(T a)
cout << "a) using template\n";
template <class T> void f(T* a)
cout << "b) using overloaded template\n";
template <> void f<int*>(int* a)
cout << "c) using specialised template\n";
int x = 1;
int* px = &x;
However, if I change the prototype of function c) from
template <> void f<*int>(int* a)
, then the compiler treats c) as a specialisation of b), and c) is called.
template <> void f<>(int* a)
Can anybody explain to me why this should be the case? I would have expected function c) to have been called in the original version too. Thanks in advance for any help.