Bibliothèque C ++ Bitset - opérateur | = Fonction

La description

La fonction C ++ std::bitset::operator|= effectue une opération OR au niveau du bit sur l'objet jeu de bits actuel.

Déclaration

Voici la déclaration de l'en-tête std :: bitset :: operator | = function form std :: bitset.

C ++ 98

bitset& operator|= (const bitset& other);

C ++ 11

bitset& operator|= (const bitset& other) noexcept;

Paramètres

other - Un autre objet bitset.

Valeur de retour

Renvoie ce pointeur.

Exceptions

Cette fonction membre ne lève jamais d'exception.

Exemple

L'exemple suivant montre l'utilisation de std :: bitset :: operator | = function.

#include <iostream>
#include <bitset>

using namespace std;

int main(void) {
   bitset<4> b("1010");
   bitset<4> mask("0101");

   /* Turn on 0th and 2nd bit */
   b |= mask;

   cout << b << endl;

   return 0;
}

Compilons et exécutons le programme ci-dessus, cela produira le résultat suivant -

1111