bitset::any
Teste s'il existe un bit dans la séquence ayant la valeur 1.
bool any( ) const;
Valeur de retour
true si tout bit dans le bitset est défini à 1 ; false si tous les bits sont 0.
Exemple
// bitset_any.cpp
// compile with: /EHsc
#include <bitset>
#include <iostream>
int main( )
{
using namespace std;
bitset<5> b1 ( 6 );
bool b, rb;
cout << "The original bitset b1( 6 ) is: ( "<< b1 << " )"
<< endl;
b = b1.any ( );
if ( b )
cout << "At least one of the bits in bitset is set to 1."
<< endl;
else
cout << "None of the bits in bitset are set to 1."
<< endl;
bitset<5> rb1;
rb1 = b1.reset ( );
cout << "The reset bitset is: ( "<< b1 << " )"
<< endl;
rb = rb1.any ( );
if ( rb )
cout << "At least one of the bits in the reset bitset "
<< "are set to 1." << endl;
else
cout << "None of the bits in bitset b1 are set to 1."
<< endl;
}
Configuration requise
En-tête : <bitset>
Espace de noms : std