Поделиться через


bitset::operator~

Переключает все биты в bitset целевого объекта и возвращает результат.

bitset<N> operator~( ) const;

Возвращаемое значение

Bitset со всеми его биты переключение по отношению к прицеленному bitset.

Пример

// bitset_op_toggle.cpp
// compile with: /EHsc
#include <iostream>
#include <string>
#include <bitset>

int main( )
{
   using namespace std;

   bitset<5> b1 ( 7 );
   bitset<5> b2;
   b2 = ~b1;

   cout << "Bitset b1 is: ( "<< b1 << " )." << endl;
   cout << "Bitset b2 = ~b1 is: ( "<< b2 << " )." << endl;

   // These bits could also be flipped using the flip member function
   bitset<5> b3;
   b3 = b1.flip( );
   cout << "Bitset b3 = b1.flip( ) is: ( "<< b2 << " )." << endl;
}
  

Требования

Заголовок:<bitset>

Пространство имен: std

См. также

Ссылки

Класс bitset