bitset all() 함수는 C++ STL(표준 템플릿 라이브러리)의 내장 함수입니다. 이 함수는 부울 값을 반환합니다. 호출 bitset의 모든 비트가 1이면 반환된 값은 true이고 그렇지 않으면 false를 반환합니다.
이 함수는 매개변수를 허용하지 않으며 부울 값을 반환합니다.
구문
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