bitset::operator~

Alterna todos los bits en un bitset de destino y devuelve el resultado.

bitset<N> operator~( ) const;

Valor devuelto

El bitset con todos los bits alternados con respecto al bitset concreto.

Ejemplo

// 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;
}
  
  
  

Requisitos

encabezado: <bitset>

espacio de nombres: std

Vea también

Referencia

bitset Class