std::bitset::all, std::bitset::any, std::bitset::none
Aus cppreference.com
<tbody>
</tbody>
bool all() const; |
(1) | (seit C++11) |
bool any() const; |
(2) | |
bool none() const; |
(3) | |
Prüft, ob alle, mindestens eines oder keines der Bits auf true gesetzt sind.
1) Prüft, ob alle Bits auf true gesetzt sind.
2) Prüft, ob mindestens ein Bit auf true gesetzt ist.
3) Prüft, ob keines der Bits auf true gesetzt ist.
Parameter
(keine)
Rückgabewert
1) true, wenn alle Bits auf true gesetzt sind, sonst false
2) true, wenn mindestens eines der Bits auf true gesetzt ist, sonst false
3) true, wenn keines der Bits true gesetzt ist, sonst false
Beispiel
#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