Cpp-standard-library-cpp-bitset-operator-biwise-and-self
提供:Dev Guides
C ++ビットセットライブラリ-operator&=関数
宣言
- 以下は、std
- bitsetヘッダーからのstd :: bitset :: operator&=関数の宣言です。
C 98
bitset& operator&= (const bitset& other);
C 11
bitset& operator&= (const bitset& other) noexcept;
パラメーター
*other* -別のビットセットオブジェクト。
戻り値
`+ 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