编译器错误 C3217

“param”: 泛型参数不能在此声明中进行约束

约束的格式错误;约束泛型参数必须与泛型类模板参数一致。

下面的示例生成 C3217:

// C3217.cpp
// compile with: /clr
interface struct A {};

generic <class T>
ref class C {
   generic <class T1>
   where T : A   // C3217
   void f();
};

以下示例演示了可能的解决方法:

// C3217b.cpp
// compile with: /clr /c
interface struct A {};

generic <class T>
ref class C {
   generic <class T1>
   where T1 : A
   void f();
};