AND の論理的な操作と bitsets のビットごとの組み合わせに実行します。
bitset<N>& operator&=(
const bitset<N>& _Right
);
パラメーター
- _Right
ターゲットの bitset およびビットごとに結合する bitset。
戻り値
パラメーターとして指定された bitset との AND 操作にビットごとに発生する変更されたターゲットの bitset。
解説
AND の演算子で結合する 2 ビットは各ビットが true の場合はを返します true ; それ以外の組み合わせは falseを返します。
Bitsets はメンバー演算子の関数によって AND のビット処理演算子と結合する同じサイズである必要があります。
使用例
// bitset_op_bitwise.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 AND combination,\n"
<< " the target bitset b1 becomes: ( "<< b1 << " )."
<< endl;
// Note that the parameter-specified bitset is 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