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

Efficiently exchange the value of this object with `other`&apos;s value&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
void
swap(xref:bsl/variant.adoc[variant]& other);
----

== Description

Efficiently exchange the value of this object with the value of the specified `other` object&period; This method provides the no&hyphen;throw exception&hyphen;safety guarantee if the two swapped objects contain the same alternative and if that alternative `t&lowbar;TYPE` provides that guarantee&period; If `&ast;this` and `other` do not have the same active alternative and this method exits via an exception, either or both `variant` objects may be left in a valueless state or with an contained value in a moved&hyphen;from state&period; The behavior is undefined unless `&ast;this` has the same allocator as `other`&period; All alternatives shall be move constructible and swappable&period; For simplicity of implementation, this method differs from the standard in the following ways&colon; &ast; `constexpr` is not implemented &ast; `noexcept` specification is not implemented

== Parameters

[cols="1,4"]
|===
| Name| Description
| *other*
| variant to exchange values with
|===


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