C++ Bitset 库 - operator&= 函数
声明
以下是 std::bitset::operator&= 函数形式 std::bitset 头的声明。
C++98
bitset& operator&= (const bitset& other);
C++11
bitset& operator&= (const bitset& other) noexcept;
参数
other − 另一个 bitset 对象。
返回值
返回 this 指针。
异常
此成员函数从不抛出异常。
示例
以下示例显示了 std::bitset::operator&= 函数的用法。
#include <iostream>
#include <bitset>
using namespace std;
int main(void) {
bitset<4> b("1010");
bitset<4> mask("1000");
/* Turn off all bits except 3rd bit */
b &= mask;
cout << b << endl;
return 0;
}
让我们编译并运行上面的程序,这将产生以下结果 −
1000

