[英]What is the relevance of this statement in 7.1.6.1/1 in the C++ Standard?
7.1.6.1/1 contains the following statement (emphasis mine): 7.1.6.1/1包含以下声明(强调我的):
There are two cv-qualifiers , const and volatile.
有两个cv限定符 ,const和volatile。 If a cv-qualifier appears in a decl-specifier-seq , the init-declarator-list of the declaration shall not be empty .
如果cv-qualifier出现在decl-specifier-seq中 ,则声明的init-declarator-list不应为空 。
What is the relevance of the statement in bold above? 以上粗体语句的相关性是什么? In other words, is it possible to produce an example of a cv-unqualified type in a decl-specifier-seq , in which the init-declarator-list of the declaration is empty?
换句话说,是否可以在decl-specifier-seq中生成cv-unqualified类型的示例,其中声明的init-declarator-list为空?
Sure, most class and enum definitions make use of it: 当然,大多数类和枚举定义都使用它:
struct A { }; // valid
const struct B { }; // invalid, const would have no meaning
const struct C { } c { }; // valid
There is nothing else. 没有别的。 An init-declarator-list is only used in a simple-declaration, and for that, the standard (C++11) states:
init-declarator-list仅用于简单声明,为此,标准(C ++ 11)声明:
7 Declarations [dcl.dcl]
7声明[dcl.dcl]
3 In a simple-declaration , the optional init-declarator-list can be omitted only when declaring a class (Clause 9) or enumeration (7.2), that is, when the decl-specifier-seq contains either a class-specifier , an elaborated-type-specifier with a class-key (9.1), or an enum-specifier .
3在一个简单声明中 ,只有在声明一个类(第9节)或枚举(7.2)时,也就是说,当decl-specifier-seq包含一个类说明符时 ,可以省略可选的init-declarator-list。 elaborated-type-specifier ,带有类键 (9.1)或枚举说明符 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.