Share via


bitset::operator|=

執行位元 bitsets 的組合含有 OR 作業。

bitset<N>& operator|=(
   const bitset<N>& _Right
);

參數

  • _Right
    要結合位元目標 bitset 的 bitset。

傳回值

由於使用做為參數指定的 bitset 的位元包含 OR 作業已修改的目標 bitset。

備註

如果至少有一個位元是 true,包含 OR 運算子結合的兩個位 true 傳回;如果兩個位元是 false,它們的組合中傳回 false

Bitsets 必須將位元的 OR 運算結合的相同大小與包含 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

請參閱

參考

bitset Class