gpt4 book ai didi

c++ - 我认为这是 C++11 标准中的一个(小)缺陷

转载 作者:可可西里 更新时间:2023-11-01 18:26:21 28 4
gpt4 key购买 nike

我认为这是 C++11 标准中的一个(次要)缺陷。在 [dcl.dcl] 中我们有:

simple-declaration:

          decl-specifier-seqopt init-declarator-listopt ;

decl-specifier-seq 不能是可选的。

例如下面的代码片段无法编译:

x;

如果我在这里是正确的,那么 §8.3/1 段的开头也应该更改:

来自:

A list of declarators appears after an optional (Clause 7)decl-specifier-seq (7.1).

收件人:

A list of declarators appears after a decl-specifier-seq (7.1).

最佳答案

评论太长

第 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. 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). 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.

第 7 条第 9 段

Only in function declarations for constructors, destructors, and type conversions can the decl-specifier-seq be omitted.

关于c++ - 我认为这是 C++11 标准中的一个(小)缺陷,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27081344/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com