最終更新日時(UTC):
が更新

履歴 編集

function
<bitset>

std::bitset::operator^=

bitset<N>& operator^=(const bitset<N>& rhs);                    // (1) C++03
bitset<N>& operator^=(const bitset<N>& rhs) noexcept;           // (1) C++11
constexpr bitset<N>& operator^=(const bitset<N>& rhs) noexcept; // (1) C++23

概要

*thisrhsに対して、排他的論理和(XOR)の複合演算を行う。

効果

*thisに対して、*thisrhsのどちらか一方だけ1であればビットを1にし、それ以外のビットを0にする。

戻り値

*this

例外

投げない。

#include <iostream>
#include <bitset>

int main()
{
  std::bitset<4> bs1("0011");
  std::bitset<4> bs2("0101");

  bs1 ^= bs2;

  std::cout << bs1 << std::endl;
}

出力

0110

参照