编译器错误 C2784

“declaration”: 对于“type”,无法从“type”推导其模板参数

编译器无法从提供的函数参数确定模板参数。

下面的示例生成 C2784,并演示如何修复此错误:

// C2784.cpp
template<class T> class X {};
template<class T> void f(X<T>) {}

int main() {
   X<int> x;
   f(1);   // C2784

   // To fix it, try the following line instead
   f(x);
}