Skip to content

Latest commit

 

History

History
78 lines (58 loc) · 1.77 KB

File metadata and controls

78 lines (58 loc) · 1.77 KB

operator>

  • map[meta header]
  • std[meta namespace]
  • function template[meta id-type]
namespace std {
  // operator<=>により、以下の演算子が使用可能になる (C++20)
  template <class Key, class T, class Compare, class Allocator>
  bool
    operator>(const map<Key,T,Compare,Allocator>& x,
              const map<Key,T,Compare,Allocator>& y); // (1) C++03
  template <class Key, class T, class Compare, class Allocator>
  constexpr bool
    operator>(const map<Key,T,Compare,Allocator>& x,
              const map<Key,T,Compare,Allocator>& y); // (1) C++26
}

概要

xy より大きいかどうかの判定を行う。

パラメータ

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

戻り値

xy より大きい場合に true, そうでない場合に false

計算量

size に対して線形時間。

#include <iostream>
#include <map>

int main()
{
  std::map<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;

  m1.insert(std::make_pair('d',40));

  std::cout << (m1 > m2) << std::endl;

  return 0;
}
  • m1.insert[link insert.md]

出力

0
1

処理系

参照