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

std::bitset<N>::operator&=,|=,^=,~ cppreference.com
cppreference.com

std::bitset<N>::operator&=,|=,^=,~

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> <tbody class="t-dcl-rev t-dcl-rev-num "> </tbody><tbody> </tbody>
(1)
bitset& operator&=( const bitset& other );
( C++11)
bitset& operator&=( const bitset& other ) noexcept;
( C++11)
(constexpr C++23)
(2)
bitset& operator|=( const bitset& other );
( C++11)
bitset& operator|=( const bitset& other ) noexcept;
( C++11)
(constexpr C++23)
(3)
bitset& operator^=( const bitset& other );
( C++11)
bitset& operator^=( const bitset& other ) noexcept;
( C++11)
(constexpr C++23)
(4)
bitset operator~() const;
( C++11)
bitset operator~() const noexcept;
( C++11)
(constexpr C++23)

, , .

1) *this other.
2) *this other.
3) *this other.
4) *this ( ).

, &=, |= ^= N.

other

1-3) *this
4) bitset<N>(*this).flip()

#include <iostream>
#include <string>
#include <bitset>

int main()
{
    const std::string pattern_str{"1001"};
    std::bitset<16> pattern{pattern_str}, dest;
 
    for (std::size_t i = dest.size()/pattern_str.size(); i != 0; --i) {
        dest <<= pattern_str.size();
        dest |= pattern;
        std::cout << dest << " (i = " << i << ")\n";
    }

    std::cout << ~dest << " (~dest)\n";
}

:

0000000000001001 (i = 4)
0000000010011001 (i = 3)
0000100110011001 (i = 2)
1001100110011001 (i = 1)
0110011001100110 (~dest)


(public -) []

Web Proxy Viewer  |  New URL  |  Original Page