- set[meta header]
- std[meta namespace]
- function template[meta id-type]
namespace std {
template <class Key, class Compare, class Allocator>
void swap(multiset<Key, Compare, Allocator>& x,
multiset<Key, Compare, Allocator>& y);
template <class Key, class Compare, class Allocator>
void swap(multiset<Key, Compare, Allocator>& x,
multiset<Key, Compare, Allocator>& y)
noexcept(noexcept(x.swap(y))); // C++17
}
2つのmultiset
オブジェクトを入れ替える。
x.swap(y);
- swap[link swap.md]
定数時間
#include <iostream>
#include <set>
int main()
{
std::multiset<int> c1, c2;
c1.insert(10);
c1.insert(20);
c1.insert(30);
c2.insert(5);
c2.insert(15);
std::swap(c1, c2);
std::multiset<int>::iterator i = c1.begin();
while (i != c1.end()) {
std::cout << *(i++) << ",";
}
std::cout << std::endl;
}
- std::swap[color ff0000]
- insert[link insert.md]
- c1.begin()[link begin.md]
- c1.end()[link end.md]
5,15,
- N4258 Cleaning-up noexcept in the Library, Rev 3
noexcept
追加の経緯となる提案文書