Cpp-standard-library-cpp-bitset-opertor-bitwise-not

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

C ++ビットセットライブラリ-operator〜関数

説明

C ++関数* std
bitset :: operator〜*は、ビットセットに対してビット単位のNOT演算を実行します。

宣言

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

C 98

bitset operator~() const;

C 11

bitset operator~() const noexcept;

パラメーター

None

戻り値

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

例外

すべてのビットが反転した一時ビットセットを返します。

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

using namespace std;

int main(void) {
   bitset<4> b("0000");

   cout << ~b << endl;

   return 0;
}

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

1111