Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
STL Containers
bitset
deque
list
map
multimap
multiset
priority_queue
queue
set
stack
vector
bitset
bitset::bitset
bitset operators
member functions:
bitset::any
bitset::count
bitset::flip
bitset::none
bitset::operator[]
bitset::reset
bitset::set
bitset::size
bitset::test
bitset::to_string
bitset::to_ulong


bitset::any

public member function
bool any ( ) const;

Test if any bit is set

Returns whether any of the bits in the bitset is set.

Parameters

none

Return value

true if any of the bits in the bitset is set, and false otherwise.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// bitset::any
#include <iostream>
#include <bitset>
using namespace std;
int main ()
{
  bitset<16> mybits;
  cout << "enter a binary number: ";
  cin >> mybits;
  if (mybits.any())
    cout << "mybits has " << (int)mybits.count() << " bits set.\n";
  else cout << "mybits has no bits set.\n";
  return 0;
}


See also