显式专用化“declaration”不是函数模板的专用化
无法特化非模板函数。
以下示例生成 C2912:
// C2912.cpp
// compile with: /c
void f(char);
template<> void f(char); // C2912
template<class T> void f(T); // OK
此外,在 Visual Studio .NET 2003 中完成的编译器一致性工作也会导致生成此错误:对于每个显式专用化,必须选择显式专用化参数,只有这样它们才会匹配主模板的参数。
// C2912b.cpp
class CF {
public:
template <class A> CF(const A& a) {} // primary template
// attempted explicit specialization
template <> CF(const char* p) {} // C2912
// try the following line instead
// template <> CF(const char& p) {}
};