[#bsl-swap-05b]
= xref:bsl.adoc[bsl]::swap
:relfileprefix: ../
:mrdocs:

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;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class KEY,
    class HASH,
    class EQUAL,
    class ALLOCATOR&gt;
void
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]#Created with https://www.mrdocs.com[MrDocs]#
