
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
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.
Syntax
Bool bitset_name .all()
Sample
Bitset = 100101
Output
false
Because all bits of the set need to be true in order to return a true value.
Example
#include <bits/stdc++.h> using namespace std; void printer(bool val){ if(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; printer(bit1.all()); cout<<"The bitset is "<<bit2<<endl; printer(bit2.all()); return 0; }
Output
The bitset is 1011 The bitset does not have all bits set The bitset is 111111 The bitset has all bits set
- Related Articles
- bitset::flip() in C++ STL
- sinh() function in C++ STL
- cosh() function in C++ STL
- atanh() function in C++ STL
- tanh() function in C++ STL
- acosh() function in C++ STL
- asinh() function in C++ STL
- acos() function in C++ STL
- atan2() function in C++ STL
- iswalnum() function in C++ STL
- iswalpha() function in C++ STL
- lldiv() function in C++ STL
- negate function in C++ STL
- iswpunct() function in C++ STL
- iswspace() function in C++ STL

Advertisements