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

履歴 編集

function template
<inplace_vector>

std::operator==(C++26)

namespace std {
  template <class T, std::size_t N>
  constexpr bool operator==(const inplace_vector<T, N>& x,
                            const inplace_vector<T, N>& y); // (1) C++26
}

概要

inplace_vectorオブジェクトの等値比較を行う。

要件

T==で比較可能であること。

戻り値

xyの要素数および要素の値が等しければtrue、そうでなければfalseを返す。

計算量

線形時間。ただし、xyのサイズが異なる場合は定数時間。

備考

  • この演算子により、以下の演算子が使用可能になる:
    • operator!=

#include <print>
#include <inplace_vector>

int main()
{
  std::inplace_vector<int, 5> v1 = {1, 2, 3};
  std::inplace_vector<int, 5> v2 = {1, 2, 3};
  std::inplace_vector<int, 5> v3 = {1, 2, 4};

  // operator==
  std::println("{}", (v1 == v2));
  std::println("{}", (v1 == v3));

  // operator==から自動導出されるoperator!=
  std::println("{}", (v1 != v2));
  std::println("{}", (v1 != v3));
}

出力

true
false
false
true

バージョン

言語

  • C++26

処理系

参照