Cpp-standard-library-cpp-bitset-flip-single
提供:Dev Guides
C ++ビットセットライブラリ-flip()関数
説明
- C ++関数* std
- bitset :: flip()*は、ビットセットから単一ビットを切り替えます。
宣言
- 以下は、std
- bitsetヘッダーからのstd :: bitset :: flip()関数の宣言です。
C 98
bitset& flip (size_t pos);
C 11
bitset& flip (size_t pos);
パラメーター
*pos* -値が反転されるビットの位置。
戻り値
`+ this +`ポインタを返します。
例外
「+ pos 」がビットセットサイズ以上の場合、「 out_of_range +」例外をスローします。
例
- 次の例は、std
- bitset :: flip()関数の使用方法を示しています。
#include <iostream>
#include <bitset>
using namespace std;
int main(void) {
bitset<4> b("1110");
cout << "Before flip operation b = " << b << endl;
b.flip(1);
cout << "After flip operation b = " << b << endl;
return 0;
}
上記のプログラムをコンパイルして実行すると、次の結果が生成されます-
Before flip operation b = 1110
After flip operation b = 1100