C++ 标准规定:
模板定义一系列类或函数。
模板声明:
导出优化模板<模板参数列表>宣言
模板声明中的声明应
- 声明或定义函数或类,或者
- 定义类模板或嵌套在类模板中的类的成员函数、成员类或静态数据成员,或者
- 定义类的成员模板或类模板。
这些要点中的第三点让我感到困惑。在这种情况下,“类的成员模板”的示例是什么?成员函数或嵌套类定义将包含在前两个类别之一中。当然不存在模板化数据成员这样的东西吗?这是指 typedef 吗?
The C++ standard states:
A template defines a family of classes or functions.
template-declaration:
exportopt template < template-parameter-list > declaration
The declaration in a template-declaration shall
- declare or define a function or a class, or
- define a member function, a member class or a static data member of a class template or of a class nested within a class template, or
- define a member template of a class or class template.
The third of these bullet points is what is confusing me. What is an example of "a member template of a class" in this context? A member function or nested class definition would be included in one of the first two categories. Surely there's no such thing as a templatised data member? Is this referring to typedefs?
发布评论
评论(1)
类的成员模板是一个成员函数,它本身就是一个模板,如下所示:
A member template of a class is a member function that is itself a template, like these: