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

履歴 編集

function
<bitset>

std::bitset::operator==

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

概要

*thisrhsを等値比較する。

戻り値

*thisrhsの全てのビット値が等しければtrue、そうでなければfalseを返す。

例外

投げない。

備考

  • この演算子により、operator!=が使用可能になる (C++20)

#include <iostream>
#include <bitset>

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

  if (bs1 == bs2) {
    std::cout << "equal" << std::endl;
  }
  else {
    std::cout << "not equal" << std::endl;
  }
}

出力

equal

参照