template <class T, class Container, class Compare> void swap (priority_queue<T,Container,Compare>& x, priority_queue<T,Container,Compare>& y) noexcept(noexcept(x.swap(y)));
1234567891011121314151617
// swap priority_queues #include <iostream> // std::cout #include <queue> // std::priority_queue, std::swap(priority_queue) int main () { std::priority_queue<int> foo,bar; foo.push (15); foo.push(30); foo.push(10); bar.push (101); bar.push(202); swap(foo,bar); std::cout << "size of foo: " << foo.size() << '\n'; std::cout << "size of bar: " << bar.size() << '\n'; return 0; }
size of foo: 2 size of bar: 3