operator&,|,^(std::bitset)
Min standard notice:
Header: <bitset>
Performs binary AND, OR, and XOR between two bitsets, lhs and rhs.
# Declarations
template< std::size_t N >
std::bitset<N> operator&( const std::bitset<N>& lhs,
const std::bitset<N>& rhs );
(noexcept since C++11) (constexpr since C++23)
template< std::size_t N >
std::bitset<N> operator|( const std::bitset<N>& lhs,
const std::bitset<N>& rhs );
(noexcept since C++11) (constexpr since C++23)
template< std::size_t N >
std::bitset<N> operator^( const std::bitset<N>& lhs,
const std::bitset<N>& rhs );
(noexcept since C++11) (constexpr since C++23)
# Parameters
lhs: the bitset on the left-hand side of the operatorrhs: the bitset on the right-hand side of the operator
# Example
#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';
}