We recommend using Visual Studio 2017

Compiler Error C2782


The latest version of this topic can be found at Compiler Error C2782.

declaration' : template parameter 'identifier' is ambiguous

The compiler cannot determine the type of a template argument.

The following sample generates 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 can also occur when using generics:

// 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');