

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Bitset all() function in C++ STL
<p>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.</p><p>The function does not accept any parameter and returns a Boolean value.</p><h2>Syntax</h2><pre class="result notranslate">Bool bitset_name .all()</pre><h2>Sample</h2><pre class="result notranslate">Bitset = 100101</pre><h2>Output</h2><pre class="result notranslate">false</pre><p>Because all bits of the set need to be true in order to return a true value.</p><h2>Example</h2><pre class="prettyprint notranslate">#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; }</pre><h2>Output</h2><pre class="result notranslate">The bitset is 1011 The bitset does not have all bits set The bitset is 111111 The bitset has all bits set</pre>
- Related Questions & Answers
- bitset::flip() in C++ STL
- BitSet class methods in Java
- C++ bitset interesting facts?
- 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
Advertisements