public member function
<bitset>

std::bitset::all

bool all() const noexcept;
Test if all bits are set
Returns whether all of the bits in the bitset are set (to one).

For this function to return true, all bits up to the bitset size shall be set.

Parameters

none

Return value

true if all of the bits in the bitset are set (to one), and false otherwise.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// bitset::all
#include <iostream>       // std::cin, std::cout, std::boolalpha
#include <bitset>         // std::bitset

int main ()
{
  std::bitset<8> foo;

  std::cout << "Please, enter an 8-bit binary number: ";
  std::cin >> foo;

  std::cout << std::boolalpha;
  std::cout << "all: " << foo.all() << '\n';
  std::cout << "any: " << foo.any() << '\n';
  std::cout << "none: " << foo.none() << '\n';

  return 0;
}

Possible output:

Please, enter an 8-bit binary number: 11111111
all: true
any: true
none: false


Data races

The bitset is accessed.

Exception safety

No-throw guarantee: never throws exceptions.

See also