编译器错误 C2914

“identifier”:无法推断类型参数,因为函数参数不明确

编译器无法确定要将哪些重载函数用于泛型或模板参数。

下面的示例生成 C2914:

// C2914.cpp
// compile with: /c
void f(int);
void f(double);
template<class T> void g(void (*) (T));
void h() { g(f); }   // C2914
// try the following line instead
// void h() { g<int>(f); }

在使用泛型时,也可能出现 C2914。 下面的示例生成 C2914:

// C2914b.cpp
// compile with: /clr /c
void f(int);
void f(double);

template<class T>
void gf(void (*) (T));

void h() { gf(f);}   // C2914
// try the following line instead
void h() { gf<int>(f); }