共用方式為


編譯器錯誤 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);
}