编译器错误 C2937

“class”:type-class-id 被重新定义为全局 typedef

不能将泛型或模板类用作全局 typedef

此错误在 Visual Studio 2022 及更高版本中已过时。

下面的示例生成 C2937:

// C2937.cpp
// compile with: /c
template<class T>
struct TC { };
typedef int TC<int>;   // C2937
typedef TC<int> c;   // OK

使用泛型时,也可能发生 C2937:

// C2937b.cpp
// compile with: /clr
generic<class T>
ref struct GC { };
typedef int GC<int>;   // C2937
typedef GC<int> xx;   // OK