View Single Post
  #3  
Old 10-24-2008, 12:56 PM
spoon
Sarnak
 
Join Date: Aug 2007
Posts: 34
Default

Actually it should work because bitwise operations are expressions that return an integral type. An expression doesn't have to be just a variable.

VS2005 switch definition

And our quick test proves it:

Code:
#include <iostream>
using namespace std;

int main() {
	int x = 1;
	int y = 5;
	
	switch( x | y ){
		case 0: printf("0"); break;
		case 1: printf("1"); break;
		case 2: printf("2"); break;
		case 3: printf("3"); break;
		case 4: printf("4"); break;
		case 5: printf("5"); break;
		case 6: printf("6"); break;
		case 7: printf("7"); break;
		default: printf("other"); break;
	}
}
Code:
5
Reply With Quote