Namespaces
Variants

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

cppreference.net에서 가져옴
 
 
유틸리티 라이브러리
일반 유틸리티
관계 연산자 (C++20에서 폐지됨)
정수 비교 함수
(C++20)(C++20)(C++20)    
(C++20)
swap 및 형식 연산
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
공통 어휘 형식
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)
(C++23)



 
 
bitset& operator&=( const bitset& other );
(1) (C++11부터 noexcept)
(C++23부터 constexpr)
bitset& operator|=( const bitset& other );
(2) (C++11부터 noexcept)
(C++23부터 constexpr)
bitset& operator^=( const bitset& other );
(3) (C++11부터 noexcept)
(C++23부터 constexpr)
bitset operator~() const;
(4) (C++11부터 noexcept)
(C++23부터 constexpr)

이진 AND, OR, XOR 및 NOT을 수행합니다.

1) *this과(와) other의 대응되는 비트 쌍에 대해 이진 AND를 수행한 결과로 비트를 설정합니다.
2) *this과(와) other의 대응되는 비트 쌍에 대해 이진 OR를 수행한 결과로 비트를 설정합니다.
3) *this과(와) other의 대응되는 비트 쌍에 대해 이진 XOR을 수행한 결과로 비트를 설정합니다.
4) 모든 비트가 반전된(이진 NOT) *this의 임시 복사본을 반환합니다.

&=, |=, ^=은 동일한 크기 N의 bitset에 대해서만 정의됩니다.

매개변수

other - another bitset

반환값

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

예제

#include <bitset>
#include <cstddef>
#include <iostream>
#include <string>
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 member function)