Compiler Error C3412

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

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

template' : cannot specialize template in current scope

A template cannot be specialized at class scope, only in global or namespace scope.

The following sample generates C3412.

// C3412.cpp  
template <class T>  
struct S {  
   template <>  
   struct S<int> {};   // C3412 in a class  
};  

The following sample shows a possible resolution.

// C3412b.cpp  
// compile with: /c  
template <class T>  
struct S {};  
  
template <>  
struct S<int> {};  

Show: