• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function template
    <map>

    std::operator<=>

    namespace std {
      template <class Key, class T, class Compare, class Allocator>
      synth-three-way-result<pair<const Key, T>>
        operator<=>(const multimap<Key,T,Compare,Allocator>& x,
                    const multimap<Key,T,Compare,Allocator>& y); // (1) C++20
    }
    

    概要

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

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

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

    効果

    計算量

    線形時間

    備考

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

    #include <cassert>
    #include <map>
    
    int main()
    {
      std::multimap<int, char> m1;
      m1.insert(std::make_pair(0, 'a'));
    
      auto m2 = m1;
    
      assert((m1 <=> m2) == 0);
    
      m2.insert(std::make_pair(0, 'b'));
    
      assert((m1 <=> m2) != 0);
    
      return 0;
    }
    

    出力

    処理系

    参照