std::bitset...::operator!=(3)
π
std::bitset...::operator!=(3) π
okay bestie, welcome to the C++ Standard Libary manual β yes, that's the manual name, and the page title is literally std::bitset...::operator!=(3). This one is about the comparison operators for std::bitset, and it's lowkey iconic. π«Ά
πΈ NAME πΈ
std::bitset::operator==,std::bitset::operator!= β yep, that's the whole name. And the page repeats it exactly: std::bitset::operator==,std::bitset::operator!=. Twin operator representation, we love to see it. π
β¨ Synopsis β¨
Both are const member functions, and here's the exact signature tea:
- (1)
bool operator==( const bitset& rhs ) const;βnoexceptsince C++11, andconstexprsince C++23. β¨ - (2)
bool operator!=( const bitset& rhs ) const;βnoexceptsince C++11, until C++20. π«Ά
- Returns
trueif all of the bits in*thisandrhsare equal. - Returns
trueif any of the bits in*thisandrhsare not equal.
The != operator is synthesized from operator==. (since C++20) β no cap, that's the actual rule. π
πΈ Parameters πΈ
rhsβ bitset to compare. That's it, bestie. π
π Return value π
trueif the value of each bit in*thisequals the value of the corresponding bit inrhs, otherwisefalse.trueif!(*this == rhs), otherwisefalse.
π§ Example π§
Compare given bitsets to determine if they are identical β yes, literally:
// Run this code
#include <bitset>
#include <iostream>
int main()
{
std::bitset<4> b1(0b0011);
std::bitset<4> b2(b1);
std::bitset<4> b3(0b0100);
std::cout << std::boolalpha;
std::cout << "b1 == b2: " << (b1 == b2) << '\n';
std::cout << "b1 == b3: " << (b1 == b3) << '\n';
std::cout << "b1 != b3: " << (b1 != b3) << '\n';
// b1 == std::bitset<3>{}; // compile-time error: incompatible types
}
π₯ Output π₯
That output is exactly this:
b1 == b2: true
b1 == b3: false
b1 != b3: true
okurrr, that's the whole page, bestie. It came from π http://cppreference.com, dated π
2024.06.10, and the page is literally std::bitset...::operator!=(3) π
β¨.
π¦ 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