【发布时间】:2014-05-17 08:01:57
【问题描述】:
有来自秒的报价。 N3797工作草案的3.3.1/4:
给定单个声明区域中的一组声明,每个 它指定了相同的非限定名称,
——只有一个声明应该声明一个类名或枚举 不是 typedef 名称的名称,其他声明应全部 引用相同的变量或枚举数,或全部引用函数 和函数模板;
我们可以在单个声明区域中多次声明enum 类型名称:
enum A; // declared first time, the other declaration with the same
// unqualified name shall all refer to the same variable or enumeration.
enum A; // This and the other declarations shall all refer to the that enumeration
extern int A; // Fail, now enum A is hidden and we can access it
// via elaborated-type-specifier only
我很困惑。你能解释一下这种行为吗?我想找到当前工作草案的相应参考。
【问题讨论】:
-
@IgorTandetnik 但是定义为
enum-key attribute-specifier-seq_opt identifier enum-base_opt的opaque-enum-declaration呢。 -
不是你的。 7.2/2 声明无范围枚举的 opaque-enum-declaration 不得省略 enum-base。
-
@IgorTandetnik 您确定您查看的是我在帖子中指定的相同工作草案(N3797 C++14 工作草案)吗?
标签: c++ enums language-lawyer