Bitset all() function in C++ STL

The bitset all() function an inbuilt function of the C++ STL( Standard Template Library). This function returns a Boolean value. The returned value is true if all the bits of the calling bitset are 1 else it will return false.

The function does not accept any parameter and returns a Boolean value.


Bool bitset_name .all()


Bitset = 100101



Because all bits of the set need to be true in order to return a true value.


#include <bits/stdc++.h>
using namespace std;
void printer(bool val){
      cout<< "The bitset has all bits set"<< endl;
   } else{
      cout << "The bitset does not have all bits set"<< endl;
int main() {
   bitset<4> bit1(string("1011"));
   bitset<6> bit2(string("111111"));
   cout<<"The bitset is "<<bit1<<endl;
   cout<<"The bitset is "<<bit2<<endl;
   return 0;


The bitset is 1011
The bitset does not have all bits set
The bitset is 111111
The bitset has all bits set