Suppose I have two variables of type int
, a
and b
, and a flag F
.
#define F <something>
int a = <something> ;
int b = <something> ;
What is a simple way to test that both a
and b
, have the flag F
, or none of them has it?
To test if both of them have it, I can use something like:
if ( a & b & F )
To test if none of them has it, I can use something like:
if ( !((a & F) || (b & F)) )
And the whole test becomes:
if ( (a & b & F) && !((a & F) || (b & F)) )
But this looks, too long and too complicated. Is there any simpler solution?