std::bitset<N>::operator==, std::bitset<N>::operator!=
From cppreference.com
 
 
 
 
 
 C++ 
 Feature test macros (C++20)
 Concepts library (C++20)
 Metaprogramming library (C++11)
 Ranges library (C++20)
 Filesystem library (C++17)
 Concurrency support library (C++11)
 Execution control library (C++26)
Utilities library 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
  
 
 
 Type support (basic types, RTTI)
 Library feature-test macros (C++20)
(C++11)
(C++20)
(C++26)
(C++20)
 Coroutine support (C++20)
 Contract support (C++26)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
  (C++20)(C++20)(C++20)
  (C++20)(C++20)(C++20)
 General utilities
 Relational operators (deprecated in C++20)
(C++20)(C++20)(C++20)
  (C++20)(C++20)(C++20)
(C++20)
 Swap and type operations 
 Common vocabulary types
std::bitset 
 
 
 
bitset::operator==bitset::operator!=
(until C++20)
(C++11)
(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)
1) Returns true if all of the bits in *this and rhs are equal.
2) Returns true if any of the bits in *this and rhs are not equal.
The != operator is synthesized from operator==.
[edit] Parameters
 rhs
 -
 bitset to compare
[edit] Return value
1) true if the value of each bit in *this equals the value of the corresponding bit in rhs, otherwise false.
2) true if !(*this == rhs), otherwise false.
[edit] Example
Compare given bitsets to determine if they are identical:
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:
b1 == b2: true b1 == b3: false b1 != b3: true