编译器错误 C2992

“类”: 参数列表无效或缺失

此类前加 templategeneric 关键字,存在缺失或无效的参数。

示例

以下示例生成 C2992:

// C2992.cpp
// compile with: /c
template <class T>
struct Outer {
   template <class U>
   struct Inner;
};

template <class T>   // C2992
struct Outer<T>::Inner {};

template <class T>
template <class U>   // OK
struct Outer<T>::Inner {};

使用泛型时也可能发生 C2992:

// C2992b.cpp
// compile with: /c /clr
generic <class T>
ref struct Outer {
   generic <class U>
   ref struct Inner;
};

generic <class T>   // C2992
ref struct Outer<T>::Inner {};

generic <class T>
generic <class U>   // OK
ref struct Outer<T>::Inner {};