[#BloombergLP-bslstp-Util-swapContainers]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslstp.adoc[bslstp]::xref:BloombergLP/bslstp/Util.adoc[Util]::swapContainers
:relfileprefix: ../../../
:mrdocs:

Exchange the contents of the specified containers&period;

== Synopsis

Declared in `&lt;bslstp&lowbar;util&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class CONTAINER,
    class QUICKSWAP&lowbar;FUNC&gt;
static
void
swapContainers(
    CONTAINER& c1,
    CONTAINER& c2,
    QUICKSWAP&lowbar;FUNC const& quickswap);
----

== Description

Correctly handle the case where the two containers have different allocator values&period; The `quickswap` argument is a binary function object that is called to quickly swap two `CONTAINER` objects with matching allocators&period; (The `quickswap` object does not need to check that the allocator matched &hyphen;&hyphen; it is guaranteed by the caller&period;) Strong exception guarantee&colon; if the allocator or copy constructor of either container throws an exception, then the values of `c1` and `c2` are left unchanged&period; The `quickswap` function must not throw an exception&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *c1*
| first container to exchange
| *c2*
| second container to exchange
| *quickswap*
| binary function object that swaps two containers with matching allocators&semi; must not throw
|===


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