operator&,|,^(std::bitset)
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 
 
 
 
 
 
 
(until C++20)
(C++11)
operator&operator|operator^
(C++11)
Defined in header 
 
 
<bitset> 
 template< std::size_t N >
 (1)
 (noexcept since C++11) std::bitset <N> operator&( const std::bitset <N>& lhs,
(constexpr since C++23)
template< std::size_t N >
 (2)
 (noexcept since C++11) std::bitset <N> operator|( const std::bitset <N>& lhs,
(constexpr since C++23)
template< std::size_t N >
 (3)
 (noexcept since C++11) std::bitset <N> operator^( const std::bitset <N>& lhs,
(constexpr since C++23)
Performs binary AND, OR, and XOR between two bitsets, lhs and rhs.
1) Returns a std::bitset <N> containing the result of binary AND on corresponding pairs of bits of lhs and rhs.
2) Returns a std::bitset <N> containing the result of binary OR on corresponding pairs of bits of lhs and rhs.
3) Returns a std::bitset <N> containing the result of binary XOR on corresponding pairs of bits of lhs and rhs.
Contents
[edit] Parameters
 lhs
 -
 the bitset on the left-hand side of the operator
 rhs
 -
 the bitset on the right-hand side of the operator
[edit] Return value
1) std::bitset <N>(lhs) &= rhs
2) std::bitset <N>(lhs) |= rhs
3) std::bitset <N>(lhs) ^= rhs
[edit] Example
Run this code
#include <bitset> #include <iostream> int main() { std::bitset <4> b1("0110"); std::bitset <4> b2("0011"); std::cout << "b1 & b2: " << (b1 & b2) << '\n'; std::cout << "b1 | b2: " << (b1 | b2) << '\n'; std::cout << "b1 ^ b2: " << (b1 ^ b2) << '\n'; }
Output:
b1 & b2: 0010 b1 | b2: 0111 b1 ^ b2: 0101