C++ bitset all function is used to test whether all bits from bitset are set or not. It returns a boolean value i.e either true or false.
Syntax
Example
bool all() const no except;
Parameter
It does not take any parameter.
Return value
It returns a boolean value either true or false.
Example 1
Example
#include <iostream>
#include <bitset>
using namespace std;
int main()
{
bitset<4> b;
bitset<4> mask("1111");
if (!b.all())
cout<< "All bits are not set." <<endl;
b |= mask;
if (b.all())
cout<< "All bit are set." <<endl;
return 0;
}
Output:
Output
All bits are not set.
All bit are set.