bitset::operator|=
執行 bitsets 執行位元組合含有 OR 作業。
bitset<N>& operator|=(
const bitset<N>& _Right
);
參數
- _Right
是與目標 bitset 組合的位元的 bitset。
傳回值
結果為參數指定的 bitset 的位元包含 OR 作業的已修改的目標 bitset。
備註
如果至少有一個位元是 true,包含 OR 運算子結合的兩個位元組傳回 true ;如果兩個位元是 false,其組合傳回 false。
Bitsets 必須是相同大小和包含 OR 運算子組合的位元由成員運算子函式。
範例
// 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;
}
需求
標題: <bitset>
命名空間: std