最終更新日時(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に対して、論理積(AND)の複合演算を行う。

効果

*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;
}

出力

0001

参照