“declaration”:已忽略此模板声明中的默认模板自变量
注解
默认模板自变量在错误的位置指定,并且已被忽略。 类模板的默认模板参数只能在类模板的声明或定义中指定,不能在类模板的成员上指定。
Example
此示例生成 C4545,下一个示例演示如何修复:
// C4544.cpp
// compile with: /W1 /LD
template <class T>
struct S
{
template <class T1>
struct S1;
void f();
};
template <class T=int>
template <class T1>
struct S<T>::S1 {}; // C4544
在此示例中,默认参数应用于类模板 S:
// C4544b.cpp
// compile with: /LD
template <class T = int>
struct S
{
template <class T1>
struct S1;
void f();
};
template <class T>
template <class T1>
struct S<T>::S1 {};