bitset::operator|=
Performs a bitwise combination of bitsets with the inclusive OR operation.
bitset<N>& operator|=(
const bitset<N>& _Right
);
Parameters
- _Right
The bitset that is to be combined bitwise with the target bitset.
Return Value
The modified target bitset that results from the bitwise inclusive OR operation with the bitset specified as a parameter.
Remarks
Two bits combined by the inclusive OR operator return true if at least one of the bits is true; if both bits are false, their combination returns false.
Bitsets must be of the same size to be combined bitwise with the inclusive OR operator by the member operator function.
Example
// bitset_op_BIO.cpp
// compile with: /EHsc
#include <bitset>
#include <iostream>
int main( )
{
using namespace std;
bitset<5> b1 ( 7 );
bitset<5> b2 ( 11 );
bitset<4> b3 ( 7 );
cout << "The target bitset b1 is: ( "<< b1 << " )." << endl;
cout << "The parameter bitset b2 is: ( "<< b2 << " )." << endl;
cout << endl;
b1 |= b2;
cout << "After bitwise inclusive OR combination,\n"
<< " the target bitset b1 becomes: ( "<< b1 << " )."
<< endl;
// Note that the parameter-specified bitset in unchanged
cout << "The parameter bitset b2 remains: ( "<< b2 << " )."
<< endl;
// The following would cause an error because the bisets
// must be of the same size to be combined
// b1 |= b3;
}
The target bitset b1 is: ( 00111 ).
The parameter bitset b2 is: ( 01011 ).
After bitwise inclusive OR combination,
the target bitset b1 becomes: ( 01111 ).
The parameter bitset b2 remains: ( 01011 ).
Requirements
Header: <bitset>
Namespace: std