C++ Bitset Library - operator~ Function



Description

The C++ function std::bitset::operator~ performs bitwise NOT operation on bitset.

Declaration

Following is the declaration for std::bitset::operator~ function form std::bitset header.

C++98

bitset operator~() const;

C++11

bitset operator~() const noexcept;

Parameters

None

Return value

Returns this pointer.

Exceptions

Returns temporary bitset whose all bits inverted.

Example

The following example shows the usage of std::bitset::operator~ function.

#include <iostream>
#include <bitset>

using namespace std;

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

   cout << ~b << endl;

   return 0;
}

Let us compile and run the above program, this will produce the following result −

1111
bitset.htm
Advertisements