简体   繁体   English

我认为这是C ++ 11标准中的(次要)缺陷

[英]I believe this to be a (minor) defect in the C++11 Standard

I believe this to be a (minor) defect in the C++11 Standard. 我认为这是C ++ 11标准中的(次要)缺陷。 In [dcl.dcl] we have: 在[dcl.dcl]中我们有:

simple-declaration : 简单声明

decl-specifier-seq opt init-declarator-list opt ; decl-specifier-seq opt init-declarator-list opt ;

The decl-specifier-seq can't be optional. decl-specifier-seq不能是可选的。

For instance the snippet below doesn't compile: 例如,下面的代码片段无法编译:

x;

If I'm correct here, then the beginning of paragraph §8.3/1 should also be altered: 如果我在这里是正确的,那么第8.3 / 1段的开头也应该改变:

From: 从:

A list of declarators appears after an optional (Clause 7) decl-specifier-seq (7.1). 声明列表出现在可选(第7节) decl-specifier-seq (7.1)之后。

To: 至:

A list of declarators appears after a decl-specifier-seq (7.1). decl-specifier-seq (7.1)之后出现一个声明列表。

Too long for a comment 评论太久了

In clause 7, paragraph 3: 在第7条第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 . 在一个简单声明中 ,只有在声明一个类(第9节)或枚举(7.2)时,也就是说,当decl-specifier-seq包含一个类说明符时 ,可以省略可选的init-declarator-list详细说明-type-specifier ,带有类键 (9.1)或枚举说明符 In these cases and whenever a class-specifier or enum-specifier is present in the decl-specifier-seq , the identifiers in these specifiers are among the names being declared by the declaration (as class-names , enum-names , or enumerators , depending on the syntax). 在这些情况下,只要在decl-specifier-seq中存在类说明符枚举说明符,这些说明符中的标识符就是声明声明的名称 (作为类名枚举名枚举符,取决于语法)。 In such cases, and except for the declaration of an unnamed bit-field (9.6), the decl-specifier-seq shall introduce one or more names into the program, or shall redeclare a name introduced by a previous declaration. 在这种情况下,除了声明未命名的位字段(9.6)之外, decl-specifier-seq应在程序中引入一个或多个名称,或者重新声明由先前声明引入的名称。

And in clause 7, paragraph 9 并在第7条第9款中

Only in function declarations for constructors, destructors, and type conversions can the decl-specifier-seq be omitted. 只有在构造函数,析构函数和类型转换的函数声明中,才能省略decl-specifier-seq

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM