我有以下代码:
//1
template<typename T>
void c(T in) {
cout << "Template c(" << in << ")" << endl;
}
//2
template<>
void c<>(int* in) {
cout << "Template specialization b(" << in << ")" <<endl;
}
//3
template<typename T>
void c(T* in) {
cout << "Template for pointers c(" << in << ")" <<endl;
}
//..
int i = 8;
c(&i);
有人可以解释一下为什么在下面的示例中编译器选择函数#3,但是当我更改函数#2 和#3 的顺序时,编译器选择函数#2?