按位运算bitsets的组合与逻辑 AND 操作。
bitset<N>& operator&=(
const bitset<N>& _Right
);
参数
- _Right
将按位组合与目标bitset的bitset。
返回值
按位产生为参数指定的bitset的 AND 操作的修改后的目标bitset。
备注
如果每个为true,AND 运算符组合的两个返回 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