“class”:模板参数“param”:“arg”:涉及带有内部链接的对象的表达式不能用作非类型参数
不能将静态变量的名称或地址用作模板参数。 模板类需要可在编译时评估的常量值。
下面的示例生成 C2970:
// C2970.cpp
// compile with: /c
static int si;
// could declare nonstatic to resolve all errors
// int si;
template <int i>
class X {};
template <int *pi>
class Y {};
X<si> anX; // C2970 cannot use static variable in templates
// this would also work
const int i = 10;
X<i> anX2;