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

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

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class VALUE&lowbar;TYPE,
    class ALLOCATOR&gt;
void
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)));
----

== Description

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;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *a*
| first deque to swap
| *b*
| second deque to swap
|===


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