std::queue swap()
- od C++11
// Non const version only
void swap( priority_queue& other ) noexcept(/* see below*/);
Exchanges the contents of the container adaptor with those of other
.
Effectively does:
using std::swap;
swap(c, other.c);
Parameters
other
- container adaptor to exchange the contents with
Return valued
(none)
Exceptions
- od C++17
- od C++11
noexcept specification:
noexcept(std::is_nothrow_swappable_v<Container> &&
std::is_nothrow_swappable_v<Compare>)
noexcept specification:
noexcept(noexcept(swap(c, other.c)) && noexcept(swap(comp, other.comp)))
In the expression above, the identifier swap is looked up in the same manner as the one used by the C++17 std::is_nothrow_swappable
trait.
Complexity
Equivalent to that of swap
of the underlying container.
For standard containers the complexity is guaranteed to be:
- Linear in the size of the container - O(size()), for
std::array
. - Constant - O(1), for all other containers.
Notes
Some implementations (e.g. libc++) provide the swap member function as an extension to pre-C++11 modes.
Example
This section requires improvement. You can help by editing this doc page.