Or another way to phrase this would be: can the compiler assume that an instance of an enum
can only hold values it is declared to hold and optimize based on that assumption?
enum MyType { A = 1, B = 2 };
const MyType C = static_cast<MyType>(3);
void fun(MyType m) {
switch (m) {
case A:
// ...
break;
case B:
// ...
break;
case C:
// can this be optimized away?
}
}