बिटसेट ऑल () C++ STL (स्टैंडर्ड टेम्प्लेट लाइब्रेरी) के इनबिल्ट फंक्शन को फंक्शन करता है। यह फ़ंक्शन एक बूलियन मान देता है। लौटाया गया मान सत्य है यदि कॉलिंग बिटसेट के सभी बिट 1 हैं तो यह गलत लौटाएगा।
फ़ंक्शन किसी भी पैरामीटर को स्वीकार नहीं करता है और एक बूलियन मान देता है।
सिंटैक्स
Bool bitset_name .all()
नमूना
Bitset = 100101
आउटपुट
false
क्योंकि सही मान वापस करने के लिए सेट के सभी बिट्स का सही होना आवश्यक है।
उदाहरण
#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;
} आउटपुट
The bitset is 1011 The bitset does not have all bits set The bitset is 111111 The bitset has all bits set