Skip to content

Latest commit

 

History

History
58 lines (43 loc) · 1.29 KB

op_not_equal.md

File metadata and controls

58 lines (43 loc) · 1.29 KB

operator!=

  • bitset[meta header]
  • std[meta namespace]
  • bitset[meta class]
  • function[meta id-type]
// operator==により、以下のオーバーロードが使用可能になる (C++20)
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("1110");

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

出力

not equal

参照