Compiler Error C3214

 

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 C3214.

type' : invalid type argument for generic parameter 'param' of generic 'generic_type', does not meet constraint 'constraint'

The type was specified for an instantiation of a generic class that does not meet the generic class's constraint.

The following sample generates C3214:

// C3214.cpp  
// compile with: /clr  
interface struct A {};  
  
generic <class T>   
where T : A  
ref class C {};  
  
ref class X : public A {};  
  
int main() {  
   C<int>^ c = new C<int>;   // C3214  
   C<X ^> ^ c2 = new C<X^>;   // OK  
}  

Show: