• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function template
    <map>

    std::operator<=

    namespace std {
      // operator<=>により、以下の演算子が使用可能になる (C++20)
      template <class Key, class T, class Compare, class Allocator>
      bool
        operator<=(const multimap<Key,T, Compare,Allocator>& x,
                   const multimap<Key,T, Compare,Allocator>& y); // (1) C++03
    }
    

    概要

    xy より小さいか等しいかの判定を行う。

    引数

    • x, y
      比較するコンテナ。

    戻り値

    xy より小さいか等しい場合に true, そうでない場合に false

    計算量

    size に対して線形時間。

    #include <iostream>
    #include <map>
    
    int main()
    {
      std::multimap<char, int> m1, m2;
      m1.insert(std::make_pair('a', 10));
      m1.insert(std::make_pair('b', 20));
      m1.insert(std::make_pair('c', 30));
      m2 = m1;
    
      std::cout << (m1 <= m2) << std::endl;
    
      m2.insert(std::make_pair('d', 40));
    
      std::cout << (m1 <= m2) << std::endl;
    
      return 0;
    }
    

    出力

    1
    1
    

    参照