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

Efficiently exchange the values of the specified `lhs` and `rhs` objects&period; This method provides the no&hyphen;throw guarantee if the two variant objects being swapped have the same active alternative and that alternative provides that guarantee&semi; otherwise, this method provides the basic guarantee&period; If `lhs` and `rhs` do not contain the same alternative or they have unequal allocators, and an exception is thrown during the swap, either or both variant objects may be left in a valueless state or with an alternative in a moved&hyphen;from state&period; All alternatives shall be move constructible and swappable&period; For simplicity of implementation, this function differs from the standard in the following &colon; &ast; constraints are not implemented &ast; constexpr is not implemented

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class t&lowbar;HEAD,
    class&period;&period;&period; t&lowbar;TAIL&gt;
void
swap(
    xref:bsl/variant.adoc[bsl::variant&lt;t&lowbar;HEAD, t&lowbar;TAIL&period;&period;&period;&gt;]& lhs,
    xref:bsl/variant.adoc[bsl::variant&lt;t&lowbar;HEAD, t&lowbar;TAIL&period;&period;&period;&gt;]& rhs);
----


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