Timeline for Using scoped enums for bit flags in C++
Current License: CC BY-SA 3.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 24, 2020 at 15:05 | review | Suggested edits | |||
| Mar 25, 2020 at 9:53 | |||||
| May 2, 2014 at 21:22 | comment | added | emsr | with C++11 we have std::underlying_type that provides the underlying type of an enum. So we have 'template <typename IntegralType> struct Integral { typedef typename std::underlying_type<IntegralType>::type Type; }; ` In C++14 these is even more simplified to'template <typename IntegralType> struct Integral { typedef std::underlying_type_t<IntegralType> Type; }; | |
| Mar 10, 2014 at 20:56 | comment | added | Lars Viklund | The unscoped enumerator is only declared in the surrounding scope. Being able to qualify it by the enum-name is part of lookup rules, not the declaration. C++11 7.2/10: Each enum-name and each unscoped enumerator is declared in the scope that immediately contains the enum-specifier. Each scoped enumerator is declared in the scope of the enumeration. These names obey the scope rules defined for all names in (3.3) and (3.4). | |
| Mar 10, 2014 at 19:12 | history | edited | Useless | CC BY-SA 3.0 |
implement option 3
|
| Apr 9, 2013 at 14:04 | history | edited | Useless | CC BY-SA 3.0 |
explicit namespace scoping
|
| Apr 9, 2013 at 14:00 | comment | added | Useless | That's true. The weakly-typed variant with the specified storage type adds its constants to both the enclosing scope and its own scope, iiuc. | |
| Apr 9, 2013 at 13:44 | comment | added | Daniel A.A. Pelsmaeker | Another downside of weakly typed enums is that their constants pollute my namespace, since they don't need to be prefixed with the enum name. And that may also cause all kinds of weird behavior if you have two different enums both with a member with the same name. | |
| Apr 9, 2013 at 13:35 | history | answered | Useless | CC BY-SA 3.0 |