是否可以知道非固定枚举者的范围
Is it possible to know the range of an non-fixed enumerator?
有没有办法知道枚举的值范围?我期待像std::numeric_limits
这样的type_traits
模板,但我没有找到任何人。
例如:
enum enm { A = -5, B = 3 };
std::cout << std::range_of_enum<enm>::min() << ', '
<< std::range_of_enum<enm>::max() << std::endl;
// Prints -8, 7 with two's complement representation, and -7, 7
// with one's complement representation.
注意:对于那些不知道"枚举范围"的人(虽然是一个非标准术语),请转到此问题。
no。
C 2a/2b反射建议(S)我所看的是,如果缺乏直接性状,则看起来足够强大,可以计算出来。我不知道它们在2020年被标准化的可能性,也不知道最新提案的文本保证100%。
相关文章:
- C ++枚举范围无法使用-std=c ++ 98进行编译,但使用-std=c ++ 11可以
- 如何在枚举上设置范围?
- 枚举范围无法通过 C++ 中的类中的结构访问
- 为什么可以访问范围之外的枚举器?
- 范围的枚举(枚举类)关系运营商
- 为什么可以使用范围运算符和类 A 名称在类 B 中访问类 A(公共)中的枚举
- 在C++14中,在哪个作用域中声明了重新声明枚举的非范围枚举器
- 在范围内添加位操作和转换式的枚举 - 圣诞节探索
- 枚举类别范围-C
- 是否可以知道非固定枚举者的范围
- C 在开关语句中使用特定类和枚举范围
- C++ 向前声明类范围的枚举
- C :枚举类型作为模板参数 - 全局范围
- 阵列索引(转换为整数)用范围枚举
- 使结构内定义的枚举具有全局范围C++
- 定义基于模板的映射指针,以便在验证范围时将 int 解析为枚举
- 如何使用无范围枚举器,就好像它的类型是它的基础类型一样
- 对象、枚举类型和范围的问题
- c++ -枚举范围?Bjarne Stroustrup的书
- 如何断言值是否在枚举范围内