|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member types | ||||
| Member functions | ||||
bitset::operator==bitset::operator!= (until C++20) | ||||
| Element access | ||||
| Capacity | ||||
| Modifiers | ||||
| Conversions | ||||
(C++11) | ||||
| Non-member functions | ||||
| Helper classes | ||||
(C++11) | ||||
bool operator==(const bitset& rhs)const; | (1) | (noexcept since C++11) (constexpr since C++23) |
bool operator!=(const bitset& rhs)const; | (2) | (noexcept since C++11) (until C++20) |
The | (since C++20) |
| rhs | - | bitset to compare |
Compare given bitsets to determine if they are identical:
#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:
b1 == b2: trueb1 == b3: falseb1 != b3: true