I have some code here:
case MONITORTYPE_WUXGA_SXGA_WXGA:
bResult |= (var == enum1);
bResult |= (var == enum2);
Now i know what its doin
| is the bitwise or Operator. a |= b is equal to a = a | b.
More on bitwise operations: http://en.m.wikipedia.org/wiki/Bitwise_operation
It's equivalent to:
bResult = bResult | (var == enum1);
Just like a += b means a = a + b, a |= b means a = a | b.
a |= b
is the same as
a = a | b
which is a bitwise OR operation.
It's a bitwise OR. It means the same as bResult = bResult | (value). In this case, it is setting bResult to true if var is either enum1 or enum2.
For most binary operators ♢ in C++ (except comparison operators, relational operators and boolean operators), there exists a corresponding compound assignment operator, ♢=.
That is, |= is simply the compound assignment operator for | which is bitwise or. Its use is completely equivalent to +=, *= etc. So
a |= b;
// is equivalent to
a = a | b;