Hacker News new | ask | show | jobs
by TeMPOraL 682 days ago
In the same way, an `enum class` variable's value being outside of the set defined in the `enum class` is also a fuckup.
1 comments

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.