- set[meta header]
- std[meta namespace]
- function template[meta id-type]
namespace std {
template <class Key, class Compare, class Allocator>
bool
operator==(const multiset<Key,Compare,Allocator>& x,
const multiset<Key,Compare,Allocator>& y); // (1) C++03
}x が y と等しいかどうかの判定を行う。
- C++03 :
x.size() == y.size() &&equal(x.begin(), x.end(), y.begin()); - C++14 :
equal(x.begin(), x.end(), y.begin(), y.end());
size() に対して線形時間。ただし、xとyのサイズが異なる場合は定数時間。
- この演算子により、以下の演算子が使用可能になる (C++20):
operator!=
#include <iostream>
#include <set>
int main()
{
std::multiset<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;
}- ==[color ff0000]
- insert[link insert.md]
1
0
- LWG Issue 2257. Simplify container requirements with the new algorithms
- C++14から、2つ目のイテレータ範囲のendイテレータをとる
equal()アルゴリズムを使用するようになった。
- C++14から、2つ目のイテレータ範囲のendイテレータをとる
- P1614R2 The Mothership has Landed
- C++20での三方比較演算子の追加と、関連する演算子の自動導出