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

履歴 編集

function template
<set>

std::operator>

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

概要

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

パラメータ

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

戻り値

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

計算量

size() に対して線形時間。

#include <iostream>
#include <set>

int main()
{
  std::set<int> s1, s2;
  s1.insert(10);
  s1.insert(20);
  s1.insert(30);
  s2 = s1;

  std::cout << (s1 > s2) << std::endl;

  s1.insert(40);

  std::cout << (s1 > s2) << std::endl;
}

出力

0
1

参照