c++ - 在 C++ 0x 中打开枚举类

标签 c++ enums c++11

C++ 0x 中的新“枚举类”声明是否允许开启新奇的枚举?

我问的是标准怎么说,而不是编译器支持。

最佳答案

来自 n3242 草案:

6.4.2 The switch statement [stmt.switch]

[...]

2 The condition shall be of integral type, enumeration type, or of a class type for which a single non-explicit conversion function to integral or enumeration type exists (12.3).

7.2 Enumeration declarations [dcl.enum]

[...]

enum-key:
    enum
    enum class
    enum struct

这意味着是的。

关于c++ - 在 C++ 0x 中打开枚举类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6327223/

相关文章:

c++ - 编译 Boost 链接库 (Ubuntu)

c++ - 带有模板的基于枚举的工厂无法转换类型

c# - .NET 中的标志枚举

c++ - 重用 move 的容器?

c++ - objective-c 方法中的 std::vector

c++ - 在 C++ 中多次初始化数组时会发生什么?

c# - protobuf-net 中枚举的二进制表示

C# 枚举和转换

c++ - 资源容器的包装

c++ - 如何指定我在多重继承中派生的基类?