3 ms·
I don't think reinterpret casting enums is something that should be encouraged and uncovering such points where unexpected values can be introduced is exactly t
by account42 2y ago
I don't think reinterpret casting enums is something that should be encouraged and uncovering such points where unexpected values can be introduced is exactly the point of having a strict enum. Just because putting random values into the enum isn't itself undefined behavior doesn't mean that your program isn't going to blow up later on.
Bitmask enums are also a hack and the better solution is to have different types for the individual flags (an enum) as well as a type for combinations of flags (custom type built around an integer).
Yes, these are existing uses but when enum class was designed there were no existing usages for that.
- gpderetta 2y agoHaving tried the solution with a separate type for the bitset as opposed to the enum itself, in my experience the complexity it is just not worth the improvement. > but when enum class was designed there were no existing usages for that. IIRC diverging from standard enum was considred, but rejected as deemed a surprising change in behaviour.