Exchanges the contents of the container adaptor by those of x, swapping both the underlying container value and their comparison function using the corresponding swap non-member functions (unqualified).
This member function has a noexcept specifier that matches the combined noexcept of the swap operations on the underlying container and the comparison functions.
Another priority_queue container adaptor of the same type (i.e., instantiated with the same template parameters, T, Container and Compare). Sizes may differ.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream> // std::cout
#include <queue> // std::priority_queue
int main ()
foo.push (15); foo.push(30); foo.push(10);
bar.push (101); bar.push(202);
std::cout << "size of foo: " << foo.size() << '\n';
std::cout << "size of bar: " << bar.size() << '\n';
size of foo: 2
size of bar: 3
Both *this and x are modified.
Provides the same level of guarantees as the operation performed on the underlying container objects.