Skip to main content

std::queue swap()

// Non const version only
void swap( priority_queue& other ) noexcept(/* see below*/);

Exchanges the contents of the container adaptor with those of other.

note

Effectively does:

using std::swap;
swap(c, other.c);

Parameters

  • other - container adaptor to exchange the contents with

Return valued

(none)

Exceptions

noexcept specification:

noexcept(std::is_nothrow_swappable_v<Container> &&
std::is_nothrow_swappable_v<Compare>)

Complexity

Equivalent to that of swap of the underlying container.

note

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

important

This section requires improvement. You can help by editing this doc page.

std::queue swap()

// Non const version only
void swap( priority_queue& other ) noexcept(/* see below*/);

Exchanges the contents of the container adaptor with those of other.

note

Effectively does:

using std::swap;
swap(c, other.c);

Parameters

  • other - container adaptor to exchange the contents with

Return valued

(none)

Exceptions

noexcept specification:

noexcept(std::is_nothrow_swappable_v<Container> &&
std::is_nothrow_swappable_v<Compare>)

Complexity

Equivalent to that of swap of the underlying container.

note

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

important

This section requires improvement. You can help by editing this doc page.