[ Web Proxy ]
URL:
Viewing: https://ru.cppreference.com/cpp/utility/bitset/operator_logic2 [Back]  [Original]

operator&,|,^(std::bitset) cppreference.com
cppreference.com

operator&,|,^(std::bitset)

cppreference.com
 
C++
(C++20)
(C++20)
(C++11)
(C++20)
/
(C++11)
(C++11)
(C++11)
(C++17)
 
 
 
<tbody> </tbody> <tbody class="t-dcl-rev t-dcl-rev-num "> </tbody><tbody> </tbody> <tbody class="t-dcl-rev t-dcl-rev-num "> </tbody><tbody> </tbody> <tbody class="t-dcl-rev t-dcl-rev-num "> </tbody><tbody> </tbody>
(1)
template< std::size_t N > std::bitset<N> operator&( const std::bitset<N>& lhs, const std::bitset<N>& rhs );
( C++11)
template< std::size_t N > std::bitset<N> operator&( const std::bitset<N>& lhs, const std::bitset<N>& rhs ) noexcept;
( C++11)
(constexpr C++23)
(2)
template< std::size_t N > std::bitset<N> operator|( const std::bitset<N>& lhs, const std::bitset<N>& rhs );
( C++11)
template< std::size_t N > std::bitset<N> operator|( const std::bitset<N>& lhs, const std::bitset<N>& rhs ) noexcept;
( C++11)
(constexpr C++23)
(3)
template< std::size_t N > std::bitset<N> operator^( const std::bitset<N>& lhs, const std::bitset<N>& rhs );
( C++11)
template< std::size_t N > std::bitset<N> operator^( const std::bitset<N>& lhs, const std::bitset<N>& rhs ) noexcept;
( C++11)
(constexpr C++23)

, , lhs rhs.

1) bitset<N>, lhs rhs.
2) bitset<N>, lhs rhs.
3) bitset<N>, lhs rhs.

lhs
rhs

1) bitset<N>(lhs) &= rhs
2) bitset<N>(lhs) |= rhs
3) bitset<N>(lhs) ^= rhs

#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';
}

:

b1 & b2: 0010
b1 | b2: 0111
b1 ^ b2: 0101

, ,
(public -) []

Web Proxy Viewer  |  New URL  |  Original Page