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

履歴 編集

function template
<set>

std::operator==

namespace std {
  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 と等しいかどうかの判定を行う。

戻り値

計算量

size() に対して線形時間。ただし、xyのサイズが異なる場合は定数時間。

備考

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

#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;

  s2.insert(40);

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

出力

1
0

参照