bool all() const noexcept; | (1) | (since C++11) |
| (2) | ||
bool any() const; | (until C++11) | |
bool any() const noexcept; | (since C++11) | |
| (3) | ||
bool none() const; | (until C++11) | |
bool none() const noexcept; | (since C++11) |
Checks if all, any or none of the bits are set to true.
true
true
true
(none).
true if all bits are set to true, otherwise false
true if any of the bits are set to true, otherwise false
true if none of the bits are set to true, otherwise false
#include <iostream>
#include <bitset>
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";
std::cout << b1 << '\t' << b1.all() << '\t' << b1.any() << '\t' << b1.none() << '\n';
std::cout << b2 << '\t' << b2.all() << '\t' << b2.any() << '\t' << b2.none() << '\n';
std::cout << b3 << '\t' << b3.all() << '\t' << b3.any() << '\t' << b3.none() << '\n';
}Output:
bitset all any none 0000 0 0 1 0101 0 1 0 1111 1 1 0
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/utility/bitset/all_any_none