Udostępnij za pośrednictwem


bitset::any

Sprawdzenie, czy każdy bit w sekwencji jest ustawiona na 1.

bool any( ) const;

Wartość zwracana

TRUE , jeśli każdy bit w bitset jest ustawiona na 1; FALSE , jeśli wszystkie bity są równe 0.

Przykład

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

Wymagania

Nagłówek: <bitset>

Obszar nazw: std

Zobacz też

Informacje

bitset Class