编译器错误 C2768

更新:2007 年 11 月

错误消息

“function”: 非法使用显式模板参数

编译器无法确定函数定义应是函数模板的显式专用化还是函数定义应用于新函数。

此错误作为编译器一致性增强功能的一部分在 Visual Studio .NET 2003 中引入。

有关更多信息,请参见编译时的重大更改摘要

下面的示例生成 C2768:

// C2768.cpp
template<typename T>
void f(T) {}

void f<int>(int) {}   // C2768

// an explicit specialization
template<>
void f<int>(int) {} 

// global nontemplate function overload
void f(int) {}