编译器错误 C3868
“type”: 泛型参数“parameter”上的约束与声明上的约束不同
多个声明必须具有相同的泛型约束。 有关详细信息,请参阅泛型。
示例
下面的示例生成 C3868。
// C3868.cpp
// compile with: /clr /c
interface struct I1;
generic <typename T> ref struct MyStruct;
generic <typename U> where U : I1 ref struct MyStruct; // C3868
// OK
generic <typename T> ref struct MyStruct2;
generic <typename U> ref struct MyStruct2;
generic <typename T> where T : I1 ref struct MyStruct3;
generic <typename U> where U : I1 ref struct MyStruct3;