As others have specified, yes, you can logically OR things together using failure:
case someenumvalue: //case somenumvalue case someotherenumvalue : //or case someothernumvalue do some stuff break;
But for a direct answer to your question, yes, you can make logical or bit-wise or on them (this is just a case for the result of the operation), just be careful that you get what you expect:
enum { somenumvalue1 = 0, somenumvalue2 = 1, somenumvalue3 = 2 }; int main() { int val = somenumvalue2; //this is 1 switch(val) { case somenumvalue1: //the case for 0 printf("1 %d\n", mval); break; case somenumvalue2 || somenumvalue3: //the case for (1||2) == (1), NOT the printf("2 %d\n", mval); //case for "1" or "2" break; case somenumvalue3: //the case for 2 printf("3 %d\n", mval); break; } return 0; }
If you decide to make a second implementation, keep in mind that since you || 'things, you either get 1 or 0, and thatโs like a case.
source share