编译器错误 C2782

“declaration”:模板参数“identifier”不明确

编译器无法确定模板参数的类型。

以下示例生成 C2782:

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

int main() {
   f(1, 'c');   // C2782
   // try the following line instead
   // f<int>(1, 'c');
}

使用泛型时也可能发生 C2782:

// C2782b.cpp
// compile with: /clr
generic<typename T> void gf(T, T) { }

int main() {
   gf(1, 'c'); // C2782
   // try the following line instead
   // gf<int>(1, 'c');
}