I have an enum
enum class Colors {
RED,
GREEN,
BLUE
}
and a switch statement:
switch (Colors) {
case Colors::RED:
//do something
break;
case Colors::GREEN:
//do something
break;
case Colors::BLUE:
//do something
break;
}
Is there a good way to ensure that this switch statement always has the same amount of nodes as number of values in 'Colors' and throw an error at compile time if not? I need this to work only on this specific switch statement, not other switch statements.
EDIT:
for MSVC this works:
#pragma warning(push)
#pragma warning (default: 4062)
#pragma warning (error: 4062)
function_to_which_the_warning_is_applied() {}
#pragma warning(pop)