3 ms·
Unlikely. The way it works is you define your enums like this: enum class Color { Invalid, // Not a valid value. Red, Orange, Yellow, Gre
by klodolph 4y ago
Unlikely. The way it works is you define your enums like this:
enum class Color {
Invalid, // Not a valid value.
Red,
Orange,
Yellow,
Green,
};
I think if someone's crazy enough to reclaim a 0 value in an enum or integer ID, then they're probably going to do a lot of damage to the code no matter what you do.
- benreesman 4y agoYeah, pretty much every integer enum I write has `UNKNOWN` or `INVALID` as the zero value. It adds either a `case` or a `default` to every switch and a clause or a `_` to every `match`, but it saves my ass even in non-security-sensitive settings.