- 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);
}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のサイズが異なる場合は定数時間。
#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イテレータをとる