Partager via


bitset::operator~

Bascule tous les bits dans un bitset cible et retourne le résultat.

bitset<N> operator~( ) const;

Valeur de retour

Le bitset avec tous les bits basculés par rapport à le bitset ciblé.

Exemple

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

Configuration requise

**En-tête :**bitset <de >

Espace de noms : std

Voir aussi

Référence

bitset, classe