4 ms·
I assure you I'm very critical of C++ bad defaults. But in this case I think it was the right solution. There were three options: 1. make invalid values UB. 2
by gpderetta 2y ago
I assure you I'm very critical of C++ bad defaults. But in this case I think it was the right solution. There were three options:
1. make invalid values UB.
2. make invalid values non-representable by enforcing checks.
3. enum class is just a strong integer typedef with named constants.
Luckily 1 was reject: already too much UB. 2 would require runtime checking and was not considred viable by many; also it would prevent a lot of useful cases. 3 was the remaining option and was consistent with existing enum usage.