“class”:type-class-id 重新定义为“identifier”的 typedef 成员
不能将泛型或模板类用作 typedef
成员。
此错误在 Visual Studio 2022 及更高版本中已过时。
下面的示例生成 C2933:
// C2933.cpp
// compile with: /c
template<class T> struct TC { };
struct MyStruct {
typedef int TC<int>; // C2933
};
struct TC2 { };
struct MyStruct2 {
typedef int TC2;
};
使用泛型时也可能发生 C2933:
// C2933b.cpp
// compile with: /clr /c
generic<class T> ref struct GC { };
struct MyStruct {
typedef int GC<int>; // C2933
};
ref struct GC2 { };
struct MyStruct2 {
typedef int GC2;
};