News for hackers. Stuff that matters.
Re:Enum class improvements for C++17, C++20 and C++23 by TeMPOraL on Monday August 05, 2024 @04:50AM (#41159288)
In the same way, an `enum class` variable's value being outside of the set defined in the `enum class` is also a fuckup.
Re:Enum class improvements for C++17, C++20 and C++23 by gpderetta on Monday August 05, 2024 @05:44AM (#41159553)
no, deferencing a null ptr is UB. An enum class outside the declared values is perfectly valid.

You could design a language feature where integer to enum is checked, but that's not enum.

Enum classes already add scoping, forbid implicit conversions and allow explicit underlying types. Those are pure extensions. Making undeclared values invalid or UB would be very surprising to people used to normal enums.