Cpp-standard-library-cpp-bitset-flip-all

提供:Dev Guides
移動先:案内検索

C ++ビットセットライブラリ-flip()関数

説明

C ++関数* std
bitset :: flip()*は、ビットセットのすべてのビットを切り替えます。

宣言

以下は、std
bitsetヘッダーからのstd :: bitset :: flip()関数の宣言です。

C 98

bitset& flip();

C 11

bitset& flip() noexcept;

パラメーター

None

戻り値

`+ this +`ポインタを返します。

例外

このメンバー関数は例外をスローしません。

次の例は、std
bitset :: flip()関数の使用方法を示しています。
#include <iostream>
#include <bitset>

using namespace std;

int main(void) {

   bitset<4> b("1010");

   cout << "Before flip operation b = " << b << endl;

   b.flip();

   cout << "After flip operation b = " << b << endl;

   return 0;
}

上記のプログラムをコンパイルして実行すると、次の結果が生成されます-

Before flip operation b = 1010
After flip operation b = 0101