Compiler Error C3390

Error Message

'type_arg' : invalid type argument for generic parameter 'param' of generic 'generic_type', must be a reference type

A generic type was instantiated incorrectly. Check the type definition. For more information, see Generics (Visual C++).


The following sample, using C#, creates a component that contains a generic type, with certain constraints that are not supported when authoring generic types in Visual C++ 2005. For more information, see .Constraints on Type Parameters (C# Programming Guide).

// C3390.cs
// compile with: /target:library
// a C# program
public class GR<C, V, N>
where C : class
where V : struct
where N : new() {}

The following sample generates C3390.

// C3390_b.cpp
// compile with: /clr
#using <C3390.dll>
ref class R { R(int) {} };
value class V {};
ref struct N { N() {} };

int main () {
   GR<V, V, N^>^ gr2;   // C3390 first type must be a ref type
   GR<R^, V, N^>^ gr2b;   // OK

Community Additions