std::bitset...bitset::none(3)
π std::bitset::all, std::bitset::any, std::bitset::none
okay bestie, so this is straight out of the C++ Standard Library (the manual page std::bitset...bitset::none(3)), and it's literally just three little bestie functions that vibe-check your bitset for you. No cap.
π¦ Synopsis
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)
So what's the tea on each one? π«
- Checks if all bits are set to
true. - Checks if any bits are set to
true. - Checks if none of the bits are set to
true.
that's it. that's the whole personality. three iconique little yes/no questions π
π Parameters
(none) β literally nothing, she takes no arguments, she doesn't need them, she's booked and busy πΈ
β¨ Return value
trueif all bits are set totrue, otherwisefalse.trueif any of the bits are set totrue, otherwisefalse.trueif none of the bits are set totrue, otherwisefalse.
like... the range is giving bool. no surprises here, bestie, she's consistent π
π₯ Example
go ahead and run this code, i'll wait π
#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 none
0000 0 0 1
0101 0 1 0
1111 1 1 0
the way 0000 is like "i am nothing" and 1111 is like "i AM the moment" ππ
π Defect reports
so sometimes the standards committee had to go back and fix stuff retroactively, and these are the receipts π The following behavior-changing defect reports were applied retroactively to previously published C++ standards:
LWG 693β Applied to:C++98β Behavior as published: the member functionall()was not provided β Correct behavior: provided
yeah, all() literally didn't exist in C++98 and then it did. character development fr fr π§
π See also
countβ returns the number of bits set totrue(public member function)popcount(C++20) β counts the number of 1 bits in an unsigned integer (function template)
and that's the whole page, bestie π«Ά
source: http://cppreference.com Β· version 2024.06.10 Β· page std::bitset...bitset::none(3) β ok go check your bits, ily, bye πβ¨π·
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms