编译器错误 C2785

“declaration1”和“declaration2”具有不同的返回类型

函数模板专用化的返回类型不同于主函数模板的返回类型。

更正此错误

  1. 检查函数模板的所有专用化是否一致。

示例

以下示例生成 C2785:

// C2785.cpp
// compile with: /c
template<class T> void f(T);

template<> int f(int); // C2785
template<> void f(int); // OK