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
概要
*this
とrhs
を等値比較する。
戻り値
*this
とrhs
の全てのビット値が等しければ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