|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member types | ||||
| Member functions | ||||
(until C++20) | ||||
| Element access | ||||
bitset::allbitset::anybitset::none (C++11) | ||||
| Capacity | ||||
| Modifiers | ||||
| Conversions | ||||
(C++11) | ||||
| Non-member functions | ||||
| Helper classes | ||||
(C++11) | ||||
bool all()const; | (1) | (noexcept since C++11) (constexpr since C++23) |
bool any()const; | (2) | (noexcept since C++11) (constexpr since C++23) |
bool none()const; | (3) | (noexcept since C++11) (constexpr since C++23) |
Contents |
(none)
#include <bitset>#include <iostream> int main(){std::bitset<4> b1("0000");std::bitset<4> b2("0101");std::bitset<4> b3("1111"); std::cout<<"bitset\t"<<"all\t"<<"any\t"<<"none\n"<< b1<<'\t'<< b1.all()<<'\t'<< b1.any()<<'\t'<< b1.none()<<'\n'<< b2<<'\t'<< b2.all()<<'\t'<< b2.any()<<'\t'<< b2.none()<<'\n'<< b3<<'\t'<< b3.all()<<'\t'<< b3.any()<<'\t'<< b3.none()<<'\n';}
Output:
bitset all any none0000 0 0 10101 0 1 01111 1 1 0
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 693 | C++98 | the member functionall() was not provided | provided |
| returns the number of bits set totrue (public member function)[edit] | |
(C++20) | counts the number of1 bits in an unsigned integer (function template)[edit] |