[#bsl-swap-0dc]
= xref:bsl.adoc[bsl]::swap
:relfileprefix: ../
:mrdocs:

`swap` overloads

== Synopses

Declared in `&lt;bslstl&lowbar;deque&period;h&gt;`

Set `lhs` to refer to the stop state (or lack thereof) that `rhs` referred to before the call, and vice versa&period; Implementation note&colon; this function is required by the standard to be a hidden friend (&lsqb;hidden&period;friends&rsqb;, &lsqb;stopsource&period;general&rsqb;)&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
void
xref:bsl/swap-03fc.adoc[swap](
    xref:bsl/stop_source.adoc[stop&lowbar;source]& lhs,
    xref:bsl/stop_source.adoc[stop&lowbar;source]& rhs) noexcept;
----

[.small]#xref:bsl/swap-03fc.adoc[_» more&period;&period;&period;_]#

Set `lhs` to refer to the stop state (or lack thereof) that `rhs` referred to, and vice versa&period; Implementation note&colon; this function is required by the standard to be a hidden friend (&lsqb;hidden&period;friends&rsqb;, &lsqb;stoptoken&period;general&rsqb;)&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
void
xref:bsl/swap-06da.adoc[swap](
    xref:bsl/stop_token.adoc[stop&lowbar;token]& lhs,
    xref:bsl/stop_token.adoc[stop&lowbar;token]& rhs) noexcept;
----

[.small]#xref:bsl/swap-06da.adoc[_» more&period;&period;&period;_]#

Exchange the values of the specified `a` and `b` objects&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
void
xref:bsl/swap-05ca.adoc[swap](
    xref:bsl/vector-086.adoc[vector]& a,
    xref:bsl/vector-086.adoc[vector]& b) noexcept(noexcept(a&period;d&lowbar;impl&period;swap(b&period;d&lowbar;impl)));
----

[.small]#xref:bsl/swap-05ca.adoc[_» more&period;&period;&period;_]#

Exchange the values of the specified `a` and `b` objects&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
void
xref:bsl/swap-080.adoc[swap](
    xref:bsl/vector-00d.adoc[vector&lt;void*&gt;]& a,
    xref:bsl/vector-00d.adoc[vector&lt;void*&gt;]& b) noexcept(noexcept(a&period;d&lowbar;impl&period;swap(b&period;d&lowbar;impl)));
----

[.small]#xref:bsl/swap-080.adoc[_» more&period;&period;&period;_]#

Exchange the values of the specified `a` and `b` objects&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
void
xref:bsl/swap-018.adoc[swap](
    xref:bsl/vector-00d.adoc[vector&lt;char const*&gt;]& a,
    xref:bsl/vector-00d.adoc[vector&lt;char const*&gt;]& b) noexcept(noexcept(a&period;d&lowbar;impl&period;swap(b&period;d&lowbar;impl)));
----

[.small]#xref:bsl/swap-018.adoc[_» more&period;&period;&period;_]#

Exchange the targets held by the specified `a` and specified `b` objects&period; The behavior is undefined unless &apos;a&period;get&lowbar;allocator() &equals;&equals; b&period;get&lowbar;allocator()&apos;&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class PROTOTYPE&gt;
void
xref:bsl/swap-026.adoc[swap](
    xref:bsl/function-0a.adoc[function&lt;PROTOTYPE&gt;]& a,
    xref:bsl/function-0a.adoc[function&lt;PROTOTYPE&gt;]& b) noexcept;
----

[.small]#xref:bsl/swap-026.adoc[_» more&period;&period;&period;_]#

Efficiently exchange the values of the specified `lhs` and `rhs` objects&period; This method provides the no&hyphen;throw exception&hyphen;safety guarantee if the template parameter `t&lowbar;TYPE` provides that guarantee, `lhs` and `rhs` have equal allocators, and `lhs&period;hasValue() &equals;&equals; rhs&period;hasValue()`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class t&lowbar;TYPE&gt;
void
xref:bsl/swap-04d.adoc[swap](
    xref:bsl/optional-072.adoc[bsl::optional&lt;t&lowbar;TYPE&gt;]& lhs,
    xref:bsl/optional-072.adoc[bsl::optional&lt;t&lowbar;TYPE&gt;]& rhs)
requires BloombergLP&colon;&colon;bslma&colon;&colon;UsesBslmaAllocator&lt;t&lowbar;TYPE&gt;&colon;&colon;value;
----

[.small]#xref:bsl/swap-04d.adoc[_» more&period;&period;&period;_]#

Efficiently exchange the values of the specified `lhs` and `rhs` objects&period; This method provides the no&hyphen;throw exception&hyphen;safety guarantee if the template parameter `t&lowbar;TYPE` provides that guarantee and the result of the `hasValue` method for `lhs` and `rhs` is the same&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class t&lowbar;TYPE&gt;
constexpr
void
xref:bsl/swap-0f3.adoc[swap](
    xref:bsl/optional-072.adoc[bsl::optional&lt;t&lowbar;TYPE&gt;]& lhs,
    xref:bsl/optional-072.adoc[bsl::optional&lt;t&lowbar;TYPE&gt;]& rhs)
requires !BloombergLP&colon;&colon;bslma&colon;&colon;UsesBslmaAllocator&lt;t&lowbar;TYPE&gt;&colon;&colon;value;
----

[.small]#xref:bsl/swap-0f3.adoc[_» more&period;&period;&period;_]#

Efficiently exchange the values of the specified `lhs` and `rhs` objects&period; This method provides the no&hyphen;throw exception&hyphen;safety guarantee if the template parameter `t&lowbar;TYPE` provides that guarantee and the result of the `hasValue` method for `lhs` and `rhs` is the same&period; This function can be called in constant expressions only if `t&lowbar;TYPE` is not allocator&hyphen;aware&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class t&lowbar;TYPE&gt;
void
xref:bsl/swap-00c.adoc[swap](
    xref:bsl/optional-072.adoc[bsl::optional&lt;t&lowbar;TYPE&gt;]& lhs,
    std::optional&lt;t&lowbar;TYPE&gt;& rhs)
requires !BloombergLP&colon;&colon;bslma&colon;&colon;UsesBslmaAllocator&lt;t&lowbar;TYPE&gt;&colon;&colon;value;
----

[.small]#xref:bsl/swap-00c.adoc[_» more&period;&period;&period;_]#

Exchange the values of the specified `lhs` and `rhs` optional objects&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class t&lowbar;TYPE&gt;
constexpr
void
xref:bsl/swap-089.adoc[swap](
    std::optional&lt;t&lowbar;TYPE&gt;& lhs,
    xref:bsl/optional-072.adoc[bsl::optional&lt;t&lowbar;TYPE&gt;]& rhs)
requires !BloombergLP&colon;&colon;bslma&colon;&colon;UsesBslmaAllocator&lt;t&lowbar;TYPE&gt;&colon;&colon;value;
----

[.small]#xref:bsl/swap-089.adoc[_» more&period;&period;&period;_]#

Efficiently exchange the states of the specified `a` and `b` shared pointers such that each will refer to the object formerly referred to by the other, and each will manage the object formerly managed by the other&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class ELEMENT&lowbar;TYPE&gt;
void
xref:bsl/swap-092.adoc[swap](
    xref:bsl/shared_ptr-0a.adoc[shared&lowbar;ptr&lt;ELEMENT&lowbar;TYPE&gt;]& a,
    xref:bsl/shared_ptr-0a.adoc[shared&lowbar;ptr&lt;ELEMENT&lowbar;TYPE&gt;]& b) noexcept;
----

[.small]#xref:bsl/swap-092.adoc[_» more&period;&period;&period;_]#

Efficiently exchange the states of the specified `a` and `b` weak pointers such that each will refer to the object (if any) and representation formerly referred to by the other&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class ELEMENT&lowbar;TYPE&gt;
void
xref:bsl/swap-0447.adoc[swap](
    xref:bsl/weak_ptr-0d.adoc[weak&lowbar;ptr&lt;ELEMENT&lowbar;TYPE&gt;]& a,
    xref:bsl/weak_ptr-0d.adoc[weak&lowbar;ptr&lt;ELEMENT&lowbar;TYPE&gt;]& b) noexcept;
----

[.small]#xref:bsl/swap-0447.adoc[_» more&period;&period;&period;_]#

Exchange the value of the specified `a` object with that of the specified `b` object&semi; also exchange the allocator of `a` with that of `b` if the (template parameter) type `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait, and do not modify either allocator otherwise&period; This function provides the no&hyphen;throw exception&hyphen;safety guarantee&period; This operation has `O&lsqb;1&rsqb;` complexity if either `a` was created with the same allocator as `b` or `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait&semi; otherwise, it has `O&lsqb;n &plus; m&rsqb;` complexity, where `n` and `m` are the number of elements in `a` and `b`, respectively&period; Note that this function&grave;s support for swapping objects created with different allocators when `ALLOCATOR` does not have the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait is a departure from the C&plus;&plus; Standard&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class VALUE&lowbar;TYPE,
    class ALLOCATOR&gt;
void
xref:bsl/swap-096.adoc[swap](
    xref:bsl/deque-0c.adoc[deque&lt;VALUE&lowbar;TYPE, ALLOCATOR&gt;]& a,
    xref:bsl/deque-0c.adoc[deque&lt;VALUE&lowbar;TYPE, ALLOCATOR&gt;]& b) noexcept(noexcept(a&period;swap(b)));
----

[.small]#xref:bsl/swap-096.adoc[_» more&period;&period;&period;_]#

Exchange the value of the specified `a` object with that of the specified `b` object&semi; also exchange the allocator of `a` with that of `b` if the (template parameter) type `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait, and do not modify either allocator otherwise&period; This function provides the no&hyphen;throw exception&hyphen;safety guarantee&period; This operation has `O&lsqb;1&rsqb;` complexity if either `a` was created with the same allocator as `b` or `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait&semi; otherwise, it has `O&lsqb;n &plus; m&rsqb;` complexity, where `n` and `m` are the number of elements in `a` and `b`, respectively&period; Note that this function&grave;s support for swapping objects created with different allocators when `ALLOCATOR` does not have the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait is a departure from the C&plus;&plus; Standard&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class VALUE,
    class ALLOCATOR&gt;
void
xref:bsl/swap-06d9.adoc[swap](
    xref:bsl/list-054.adoc[list&lt;VALUE, ALLOCATOR&gt;]& a,
    xref:bsl/list-054.adoc[list&lt;VALUE, ALLOCATOR&gt;]& b) noexcept(noexcept(a&period;swap(b)));
----

[.small]#xref:bsl/swap-06d9.adoc[_» more&period;&period;&period;_]#

Swap the values of the specified `a` and `b` pairs by applying `swap` to each of the `first` and `second` pair fields&period; Note that this method is no&hyphen;throw only if `swap` on each field is no&hyphen;throw&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class T1,
    class T2&gt;
void
xref:bsl/swap-0ce.adoc[swap](
    xref:bsl/pair-0b.adoc[pair&lt;T1, T2&gt;]& a,
    xref:bsl/pair-0b.adoc[pair&lt;T1, T2&gt;]& b) noexcept(noexcept(a&period;swap(b)))
requires bsl&colon;&colon;is&lowbar;swappable&lt;T1&gt;&colon;&colon;value &amp;&amp; bsl&colon;&colon;is&lowbar;swappable&lt;T2&gt;&colon;&colon;value;
----

[.small]#xref:bsl/swap-0ce.adoc[_» more&period;&period;&period;_]#

Swap the value of the specified `lhs` queue with the value of the specified `rhs` queue&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class VALUE,
    class CONTAINER&gt;
void
xref:bsl/swap-020.adoc[swap](
    xref:bsl/queue-0a5.adoc[queue&lt;VALUE, CONTAINER&gt;]& lhs,
    xref:bsl/queue-0a5.adoc[queue&lt;VALUE, CONTAINER&gt;]& rhs) noexcept(false);
----

[.small]#xref:bsl/swap-020.adoc[_» more&period;&period;&period;_]#

Swap the value of the specified `lhs` stack with the value of the specified `rhs` stack&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class VALUE,
    class CONTAINER&gt;
void
xref:bsl/swap-0cb.adoc[swap](
    xref:bsl/stack-05.adoc[stack&lt;VALUE, CONTAINER&gt;]& lhs,
    xref:bsl/stack-05.adoc[stack&lt;VALUE, CONTAINER&gt;]& rhs) noexcept(false);
----

[.small]#xref:bsl/swap-0cb.adoc[_» more&period;&period;&period;_]#

Efficiently exchange the values of the specified `lhs` and `rhs` objects&period; This method provides the no&hyphen;throw guarantee if the two variant objects being swapped have the same active alternative and that alternative provides that guarantee&semi; otherwise, this method provides the basic guarantee&period; If `lhs` and `rhs` do not contain the same alternative or they have unequal allocators, and an exception is thrown during the swap, either or both variant objects may be left in a valueless state or with an alternative in a moved&hyphen;from state&period; All alternatives shall be move constructible and swappable&period; For simplicity of implementation, this function differs from the standard in the following &colon; &ast; constraints are not implemented &ast; constexpr is not implemented


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class t&lowbar;HEAD,
    class&period;&period;&period; t&lowbar;TAIL&gt;
void
xref:bsl/swap-0f5.adoc[swap](
    xref:bsl/variant.adoc[bsl::variant&lt;t&lowbar;HEAD, t&lowbar;TAIL&period;&period;&period;&gt;]& lhs,
    xref:bsl/variant.adoc[bsl::variant&lt;t&lowbar;HEAD, t&lowbar;TAIL&period;&period;&period;&gt;]& rhs);
----

[.small]#xref:bsl/swap-0f5.adoc[_» more&period;&period;&period;_]#

Exchange the value of the specified `a` object with that of the specified `b` object&semi; also exchange the allocator of `a` with that of `b` if the (template parameter) type `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait, and do not modify either allocator otherwise&period; This function provides the no&hyphen;throw exception&hyphen;safety guarantee&period; This operation has `O&lsqb;1&rsqb;` complexity if either `a` was created with the same allocator as `b` or `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait&semi; otherwise, it has `O&lsqb;n &plus; m&rsqb;` complexity, where `n` and `m` are the number of elements in `a` and `b`, respectively&period; Note that this function&grave;s support for swapping objects created with different allocators when `ALLOCATOR` does not have the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait is a departure from the C&plus;&plus; Standard&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class VALUE&lowbar;TYPE,
    class ALLOCATOR&gt;
void
xref:bsl/swap-0a1.adoc[swap](
    xref:bsl/vector-00d.adoc[vector&lt;VALUE&lowbar;TYPE, ALLOCATOR&gt;]& a,
    xref:bsl/vector-00d.adoc[vector&lt;VALUE&lowbar;TYPE, ALLOCATOR&gt;]& b) noexcept(noexcept(a&period;swap(b)));
----

[.small]#xref:bsl/swap-0a1.adoc[_» more&period;&period;&period;_]#

Efficiently exchange the values of the specified `a` and `b` objects&period; This method provides the no&hyphen;throw exception&hyphen;safety guarantee if `a` and `b` allocators compare equal&period; Note that this function is only available for C&plus;&plus;11 (and later) language standards&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class CHAR&lowbar;TYPE,
    class CHAR&lowbar;TRAITS,
    class ALLOCATOR&gt;
void
xref:bsl/swap-0d4.adoc[swap](
    xref:bsl/basic_istringstream.adoc[basic&lowbar;istringstream&lt;CHAR&lowbar;TYPE, CHAR&lowbar;TRAITS, ALLOCATOR&gt;]& a,
    xref:bsl/basic_istringstream.adoc[basic&lowbar;istringstream&lt;CHAR&lowbar;TYPE, CHAR&lowbar;TRAITS, ALLOCATOR&gt;]& b);
----

[.small]#xref:bsl/swap-0d4.adoc[_» more&period;&period;&period;_]#

Efficiently exchange the values of the specified `a` and `b` objects&period; This method provides the no&hyphen;throw exception&hyphen;safety guarantee if `a` and `b` allocators compare equal&period; Note that this function is only available for C&plus;&plus;11 (and later) language standards&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class CHAR&lowbar;TYPE,
    class CHAR&lowbar;TRAITS,
    class ALLOCATOR&gt;
void
xref:bsl/swap-06e.adoc[swap](
    xref:bsl/basic_ostringstream.adoc[basic&lowbar;ostringstream&lt;CHAR&lowbar;TYPE, CHAR&lowbar;TRAITS, ALLOCATOR&gt;]& a,
    xref:bsl/basic_ostringstream.adoc[basic&lowbar;ostringstream&lt;CHAR&lowbar;TYPE, CHAR&lowbar;TRAITS, ALLOCATOR&gt;]& b);
----

[.small]#xref:bsl/swap-06e.adoc[_» more&period;&period;&period;_]#

Exchange the value of the specified `a` object with that of the specified `b` object&semi; also exchange the allocator of `a` with that of `b` if the (template parameter) type `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait, and do not modify either allocator otherwise&period; This function provides the no&hyphen;throw exception&hyphen;safety guarantee&period; This operation has `O&lsqb;1&rsqb;` complexity if either `a` was created with the same allocator as `b` or `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait&semi; otherwise, it has `O&lsqb;n &plus; m&rsqb;` complexity, where `n` and `m` are the lengths of `a` and `b`, respectively&period; Note that this function&grave;s support for swapping objects created with different allocators when `ALLOCATOR` does not have the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait is a departure from the C&plus;&plus; Standard&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class CHAR&lowbar;TYPE,
    class CHAR&lowbar;TRAITS,
    class ALLOCATOR&gt;
void
xref:bsl/swap-0eb7.adoc[swap](
    xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;CHAR&lowbar;TYPE, CHAR&lowbar;TRAITS, ALLOCATOR&gt;]& a,
    xref:bsl/basic_string-0faf.adoc[basic&lowbar;string&lt;CHAR&lowbar;TYPE, CHAR&lowbar;TRAITS, ALLOCATOR&gt;]& b) noexcept(noexcept(a&period;swap(b)));
----

[.small]#xref:bsl/swap-0eb7.adoc[_» more&period;&period;&period;_]#

Efficiently exchange the values of the specified `a` and `b` objects&period; This method provides the no&hyphen;throw exception&hyphen;safety guarantee if `a` and `b` allocators compare equal&period; Note that this function is only available for C&plus;&plus;11 (and later) language standards&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class CHAR&lowbar;TYPE,
    class CHAR&lowbar;TRAITS,
    class ALLOCATOR&gt;
void
xref:bsl/swap-06f.adoc[swap](
    xref:bsl/basic_stringbuf.adoc[basic&lowbar;stringbuf&lt;CHAR&lowbar;TYPE, CHAR&lowbar;TRAITS, ALLOCATOR&gt;]& a,
    xref:bsl/basic_stringbuf.adoc[basic&lowbar;stringbuf&lt;CHAR&lowbar;TYPE, CHAR&lowbar;TRAITS, ALLOCATOR&gt;]& b);
----

[.small]#xref:bsl/swap-06f.adoc[_» more&period;&period;&period;_]#

Efficiently exchange the values of the specified `a` and `b` objects&period; This method provides the no&hyphen;throw exception&hyphen;safety guarantee if `a` and `b` allocators compare equal&period; Note that this function is only available for C&plus;&plus;11 (and later) language standards&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class CHAR&lowbar;TYPE,
    class CHAR&lowbar;TRAITS,
    class ALLOCATOR&gt;
void
xref:bsl/swap-0b1.adoc[swap](
    xref:bsl/basic_stringstream.adoc[basic&lowbar;stringstream&lt;CHAR&lowbar;TYPE, CHAR&lowbar;TRAITS, ALLOCATOR&gt;]& a,
    xref:bsl/basic_stringstream.adoc[basic&lowbar;stringstream&lt;CHAR&lowbar;TYPE, CHAR&lowbar;TRAITS, ALLOCATOR&gt;]& b);
----

[.small]#xref:bsl/swap-0b1.adoc[_» more&period;&period;&period;_]#

Swap the specified `a` with the specified `b` using `a&period;swap(b)` expression&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class CHAR,
    class TRAITS,
    class ALLOCATOR&gt;
void
xref:bsl/swap-0a4.adoc[swap](
    xref:bsl/basic_syncbuf.adoc[basic&lowbar;syncbuf&lt;CHAR, TRAITS, ALLOCATOR&gt;]& a,
    xref:bsl/basic_syncbuf.adoc[basic&lowbar;syncbuf&lt;CHAR, TRAITS, ALLOCATOR&gt;]& b);
----

[.small]#xref:bsl/swap-0a4.adoc[_» more&period;&period;&period;_]#

Exchange the values of the specified `a` and `b` multisets&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class KEY,
    class COMPARATOR,
    class ALLOCATOR&gt;
void
xref:bsl/swap-001.adoc[swap](
    xref:bsl/multiset-03.adoc[multiset&lt;KEY, COMPARATOR, ALLOCATOR&gt;]& a,
    xref:bsl/multiset-03.adoc[multiset&lt;KEY, COMPARATOR, ALLOCATOR&gt;]& b) noexcept(noexcept(a&period;swap(b)));
----

[.small]#xref:bsl/swap-001.adoc[_» more&period;&period;&period;_]#

Exchange the container and comparator of the specified `a` object with the container and comparator of the specified `b` object&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class VALUE,
    class CONTAINER,
    class COMPARATOR&gt;
void
xref:bsl/swap-07d.adoc[swap](
    xref:bsl/priority_queue-034.adoc[priority&lowbar;queue&lt;VALUE, CONTAINER, COMPARATOR&gt;]& a,
    xref:bsl/priority_queue-034.adoc[priority&lowbar;queue&lt;VALUE, CONTAINER, COMPARATOR&gt;]& b) noexcept(false);
----

[.small]#xref:bsl/swap-07d.adoc[_» more&period;&period;&period;_]#

Exchange the value and comparator of the specified `a` object with those of the specified `b` object&semi; also exchange the allocator of `a` with that of `b` if the (template parameter) type `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait, and do not modify either allocator otherwise&period; This function provides the no&hyphen;throw exception&hyphen;safety guarantee if and only if the (template parameter) type `COMPARATOR` provides a no&hyphen;throw swap operation, and provides the basic exception&hyphen;safety guarantee otherwise&semi; if an exception is thrown, both objects are left in valid but unspecified states&period; This operation has `O&lsqb;1&rsqb;` complexity if either `a` was created with the same allocator as `b` or `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait&semi; otherwise, it has `O&lsqb;n &plus; m&rsqb;` complexity, where `n` and `m` are the number of elements in `a` and `b`, respectively&period; Note that this function&grave;s support for swapping objects created with different allocators when `ALLOCATOR` does not have the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait is a departure from the C&plus;&plus; Standard&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class KEY,
    class COMPARATOR,
    class ALLOCATOR&gt;
void
xref:bsl/swap-0c8.adoc[swap](
    xref:bsl/set-0d.adoc[set&lt;KEY, COMPARATOR, ALLOCATOR&gt;]& a,
    xref:bsl/set-0d.adoc[set&lt;KEY, COMPARATOR, ALLOCATOR&gt;]& b) noexcept(noexcept(a&period;swap(b)));
----

[.small]#xref:bsl/swap-0c8.adoc[_» more&period;&period;&period;_]#

Exchange the contents of the specified hash multisets&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class &lowbar;Value,
    class &lowbar;HashFcn,
    class &lowbar;EqualKey,
    class &lowbar;Alloc&gt;
void
xref:bsl/swap-079.adoc[swap](
    xref:bsl/hash_multiset.adoc[hash&lowbar;multiset&lt;&lowbar;Value, &lowbar;HashFcn, &lowbar;EqualKey, &lowbar;Alloc&gt;]& lhs,
    xref:bsl/hash_multiset.adoc[hash&lowbar;multiset&lt;&lowbar;Value, &lowbar;HashFcn, &lowbar;EqualKey, &lowbar;Alloc&gt;]& rhs);
----

[.small]#xref:bsl/swap-079.adoc[_» more&period;&period;&period;_]#

Exchange the contents of the specified hash sets&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class &lowbar;Value,
    class &lowbar;HashFcn,
    class &lowbar;EqualKey,
    class &lowbar;Alloc&gt;
void
xref:bsl/swap-075.adoc[swap](
    xref:bsl/hash_set.adoc[hash&lowbar;set&lt;&lowbar;Value, &lowbar;HashFcn, &lowbar;EqualKey, &lowbar;Alloc&gt;]& lhs,
    xref:bsl/hash_set.adoc[hash&lowbar;set&lt;&lowbar;Value, &lowbar;HashFcn, &lowbar;EqualKey, &lowbar;Alloc&gt;]& rhs);
----

[.small]#xref:bsl/swap-075.adoc[_» more&period;&period;&period;_]#

Exchange the value and comparator of the specified `a` object with those of the specified `b` object&semi; also exchange the allocator of `a` with that of `b` if the (template parameter) type `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait, and do not modify either allocator otherwise&period; This function provides the no&hyphen;throw exception&hyphen;safety guarantee if and only if the (template parameter) type `COMPARATOR` provides a no&hyphen;throw swap operation, and provides the basic exception&hyphen;safety guarantee otherwise&semi; if an exception is thrown, both objects are left in valid but unspecified states&period; This operation has `O&lsqb;1&rsqb;` complexity if either `a` was created with the same allocator as `b` or `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait&semi; otherwise, it has `O&lsqb;n &plus; m&rsqb;` complexity, where `n` and `m` are the number of elements in `a` and `b`, respectively&period; Note that this function&apos;s support for swapping objects created with different allocators when `ALLOCATOR` does not have the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait is a departure from the C&plus;&plus; Standard&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class KEY,
    class VALUE,
    class COMPARATOR,
    class ALLOCATOR&gt;
void
xref:bsl/swap-0cc.adoc[swap](
    xref:bsl/map-0a7.adoc[map&lt;KEY, VALUE, COMPARATOR, ALLOCATOR&gt;]& a,
    xref:bsl/map-0a7.adoc[map&lt;KEY, VALUE, COMPARATOR, ALLOCATOR&gt;]& b) noexcept(false);
----

[.small]#xref:bsl/swap-0cc.adoc[_» more&period;&period;&period;_]#

Exchange the value and comparator of the specified `a` object with those of the specified `b` object&semi; also exchange the allocator of `a` with that of `b` if the (template parameter) type `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait, and do not modify either allocator otherwise&period; This function provides the no&hyphen;throw exception&hyphen;safety guarantee if and only if the (template parameter) type `COMPARATOR` provides a no&hyphen;throw swap operation, and provides the basic exception&hyphen;safety guarantee otherwise&semi; if an exception is thrown, both objects are left in valid but unspecified states&period; This operation has `O&lsqb;1&rsqb;` complexity if either `a` was created with the same allocator as `b` or `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait&semi; otherwise, it has `O&lsqb;n &plus; m&rsqb;` complexity, where `n` and `m` are the number of elements in `a` and `b`, respectively&period; Note that this function&apos;s support for swapping objects created with different allocators when `ALLOCATOR` does not have the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait is a departure from the C&plus;&plus; Standard&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class KEY,
    class VALUE,
    class COMPARATOR,
    class ALLOCATOR&gt;
void
xref:bsl/swap-073.adoc[swap](
    xref:bsl/multimap-0ae.adoc[multimap&lt;KEY, VALUE, COMPARATOR, ALLOCATOR&gt;]& a,
    xref:bsl/multimap-0ae.adoc[multimap&lt;KEY, VALUE, COMPARATOR, ALLOCATOR&gt;]& b) noexcept(false);
----

[.small]#xref:bsl/swap-073.adoc[_» more&period;&period;&period;_]#

Exchange the values of the specified `a` and `b` objects&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class KEY,
    class HASH,
    class EQUAL,
    class ALLOCATOR&gt;
void
xref:bsl/swap-03d7.adoc[swap](
    xref:bsl/unordered_multiset-06c.adoc[unordered&lowbar;multiset&lt;KEY, HASH, EQUAL, ALLOCATOR&gt;]& a,
    xref:bsl/unordered_multiset-06c.adoc[unordered&lowbar;multiset&lt;KEY, HASH, EQUAL, ALLOCATOR&gt;]& b) noexcept(noexcept(a&period;swap(b)));
----

[.small]#xref:bsl/swap-03d7.adoc[_» more&period;&period;&period;_]#

Exchange the value, hasher, key&hyphen;equality functor, and `max&lowbar;load&lowbar;factor` of the specified `a` object with those of the specified `b` object&semi; also exchange the allocator of `a` with that of `b` if the (template parameter) type `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait, and do not modify either allocator otherwise&period; This function provides the no&hyphen;throw exception&hyphen;safety guarantee if and only if both the (template parameter) types `HASH` and `EQUAL` provide no&hyphen;throw swap operations&semi; if an exception is thrown, both objects are left in valid but unspecified states&period; This operation guarantees `O&lsqb;1&rsqb;` complexity&period; The behavior is undefined unless either `a` was created with the same allocator as `b` or `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class KEY,
    class HASH,
    class EQUAL,
    class ALLOCATOR&gt;
void
xref:bsl/swap-05b.adoc[swap](
    xref:bsl/unordered_set-0d2d.adoc[unordered&lowbar;set&lt;KEY, HASH, EQUAL, ALLOCATOR&gt;]& a,
    xref:bsl/unordered_set-0d2d.adoc[unordered&lowbar;set&lt;KEY, HASH, EQUAL, ALLOCATOR&gt;]& b) noexcept(noexcept(a&period;swap(b)));
----

[.small]#xref:bsl/swap-05b.adoc[_» more&period;&period;&period;_]#

Exchange the contents of the specified hash maps&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class &lowbar;Key,
    class &lowbar;Tp,
    class &lowbar;HashFcn,
    class &lowbar;EqualKey,
    class &lowbar;Alloc&gt;
void
xref:bsl/swap-030.adoc[swap](
    xref:bsl/hash_map.adoc[hash&lowbar;map&lt;&lowbar;Key, &lowbar;Tp, &lowbar;HashFcn, &lowbar;EqualKey, &lowbar;Alloc&gt;]& lhs,
    xref:bsl/hash_map.adoc[hash&lowbar;map&lt;&lowbar;Key, &lowbar;Tp, &lowbar;HashFcn, &lowbar;EqualKey, &lowbar;Alloc&gt;]& rhs);
----

[.small]#xref:bsl/swap-030.adoc[_» more&period;&period;&period;_]#

Exchange the contents of the specified hash multimaps&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class &lowbar;Key,
    class &lowbar;Tp,
    class &lowbar;HashFcn,
    class &lowbar;EqualKey,
    class &lowbar;Alloc&gt;
void
xref:bsl/swap-046.adoc[swap](
    xref:bsl/hash_multimap.adoc[hash&lowbar;multimap&lt;&lowbar;Key, &lowbar;Tp, &lowbar;HashFcn, &lowbar;EqualKey, &lowbar;Alloc&gt;]& lhs,
    xref:bsl/hash_multimap.adoc[hash&lowbar;multimap&lt;&lowbar;Key, &lowbar;Tp, &lowbar;HashFcn, &lowbar;EqualKey, &lowbar;Alloc&gt;]& rhs);
----

[.small]#xref:bsl/swap-046.adoc[_» more&period;&period;&period;_]#

Exchange the value, hasher, key&hyphen;equality functor, and `max&lowbar;load&lowbar;factor` of the specified `a` object with those of the specified `b` object&semi; also exchange the allocator of `a` with that of `b` if the (template parameter) type `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait, and do not modify either allocator otherwise&period; This function provides the no&hyphen;throw exception&hyphen;safety guarantee if and only if both the (template parameter) types `HASH` and `EQUAL` provide no&hyphen;throw swap operations&semi; if an exception is thrown, both objects are left in valid but unspecified states&period; This operation guarantees `O&lsqb;1&rsqb;` complexity&period; The behavior is undefined unless either `a` was created with the same allocator as `b` or `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class KEY,
    class VALUE,
    class HASH,
    class EQUAL,
    class ALLOCATOR&gt;
void
xref:bsl/swap-04c.adoc[swap](
    xref:bsl/unordered_map-02b.adoc[unordered&lowbar;map&lt;KEY, VALUE, HASH, EQUAL, ALLOCATOR&gt;]& a,
    xref:bsl/unordered_map-02b.adoc[unordered&lowbar;map&lt;KEY, VALUE, HASH, EQUAL, ALLOCATOR&gt;]& b) noexcept(false);
----

[.small]#xref:bsl/swap-04c.adoc[_» more&period;&period;&period;_]#

Exchange the value, hasher, key&hyphen;equality functor, and `max&lowbar;load&lowbar;factor` of the specified `a` object with those of the specified `b` object&semi; also exchange the allocator of `a` with that of `b` if the (template parameter) type `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait, and do not modify either allocator otherwise&period; This function provides the no&hyphen;throw exception&hyphen;safety guarantee if and only if both the (template parameter) types `HASH` and `EQUAL` provide no&hyphen;throw swap operations&semi; if an exception is thrown, both objects are left in valid but unspecified states&period; This operation guarantees `O&lsqb;1&rsqb;` complexity&period; The behavior is undefined unless either `a` was created with the same allocator as `b` or `ALLOCATOR` has the `propagate&lowbar;on&lowbar;container&lowbar;swap` trait&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class KEY,
    class VALUE,
    class HASH,
    class EQUAL,
    class ALLOCATOR&gt;
void
xref:bsl/swap-08c.adoc[swap](
    xref:bsl/unordered_multimap-0b0.adoc[unordered&lowbar;multimap&lt;KEY, VALUE, HASH, EQUAL, ALLOCATOR&gt;]& a,
    xref:bsl/unordered_multimap-0b0.adoc[unordered&lowbar;multimap&lt;KEY, VALUE, HASH, EQUAL, ALLOCATOR&gt;]& b) noexcept(false);
----

[.small]#xref:bsl/swap-08c.adoc[_» more&period;&period;&period;_]#


[.small]#Created with https://www.mrdocs.com[MrDocs]#
