编译器警告(等级 1)C4836
使用了非标准扩展 :“type”: 局部类型或未命名类型不能用作模板参数
C++ 标准不允许使用局部类型作为模板参数,但是 Visual C++ 编译器允许在 /Ze 下这样做。 C4836 是一个信息性的警告,让您知道您正在编写不一致的代码。 有关更多信息,请参见 /Za、/Ze(禁用语言扩展)。
默认情况下,C4836 处于关闭状态。 有关更多信息,请参见Compiler Warnings That Are Off by Default。
示例
下面的示例生成 C4836。
// C4836.cpp
// compile with: /W1
#pragma warning(default:4836)
template <class T>
struct TA {};
struct R {
public:
void f() {
struct S {};
TA<S> ta; // C4836
}
};
int main() {
R r;
r.f();
}