[#BloombergLP-bslstl-swap-0e8]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslstl.adoc[bslstl]::swap
:relfileprefix: ../../
:mrdocs:

Swap both the value, the hasher, the comparator, and the `maxLoadFactor` of the specified `x` object with the value, the hasher, the comparator, and the `maxLoadFactor` of the specified `y` object&period; Additionally, if `bslstl&colon;&colon;AllocatorTraits&lt;ALLOCATOR&gt;&colon;&colon;propagate&lowbar;on&lowbar;container&lowbar;swap` is `true`, then exchange the allocator of `x` with that of `y`, and do not modify either allocator otherwise&period; This method guarantees `O&lsqb;1&rsqb;` complexity if `x` and `y` have the same allocator or if the allocators propagate on swap, otherwise this operation will typically pay the cost of two copy constructors, which may in turn throw&period; If the allocators are the same or propagate, then this method provides the no&hyphen;throw exception&hyphen;safety guarantee unless the `swap` function of the hasher or comparator throw&period; Otherwise this method offers only the basic exception safety guarantee&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class KEY&lowbar;CONFIG,
    class HASHER,
    class COMPARATOR,
    class ALLOCATOR&gt;
void
swap(
    xref:BloombergLP/bslstl/HashTable-06.adoc[HashTable&lt;KEY&lowbar;CONFIG, HASHER, COMPARATOR, ALLOCATOR&gt;]& x,
    xref:BloombergLP/bslstl/HashTable-06.adoc[HashTable&lt;KEY&lowbar;CONFIG, HASHER, COMPARATOR, ALLOCATOR&gt;]& y);
----


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