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

履歴 編集

function template
<flat_map>

std::flat_map::operator<=>(C++23)

synth-three-way-result<value_type>
  operator<=>(const flat_map& x,
              const flat_map& y); // (1) C++23

概要

flat_mapオブジェクトの三方比較を行う。

テンプレートパラメータ制約

  • 型 (const) value_type の値に対してoperator<=>が定義されるか、型 (const) value_type の値に対してoperator<が定義され全順序をもつこと

効果

計算量

線形時間

備考

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

#include <iostream>
#include <flat_map>

int main()
{
  stdx::flat_map<int, char> fm1 = {
    {3, 'a'},
    {1, 'b'},
    {4, 'c'}
  };

  stdx::flat_map<int, char> fm2 = {
    {3, 'a'},
    {1, 'b'},
  };

  std::cout << std::boolalpha;
  std::cout << ((fm1 <=> fm1) == 0) << std::endl;
  std::cout << (fm1 < fm2) << std::endl;
  std::cout << (fm1 <= fm1) << std::endl;
  std::cout << (fm1 > fm2) << std::endl;
  std::cout << (fm2 >= fm1) << std::endl;
}

出力

true
false
true
true
false

バージョン

言語

  • C++23

処理系