[#bsl-variant-swap] = xref:bsl.adoc[bsl]::xref:bsl/variant.adoc[variant]::swap :relfileprefix: ../../ :mrdocs: Efficiently exchange the value of this object with the value of the specified `other` object. This method provides the no‐throw exception‐safety guarantee if the two swapped objects contain the same alternative and if that alternative `t_TYPE` provides that guarantee. If `*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‐from state. The behavior is undefined unless `*this` has the same allocator as `other`. All alternatives shall be move constructible and swappable. For simplicity of implementation, this method differs from the standard in the following ways: * `constexpr` is not implemented * `noexcept` specification is not implemented == Synopsis Declared in `<bslstl_variant.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- void swap(xref:bsl/variant.adoc[variant]& other); ---- [.small]#Created with https://www.mrdocs.com[MrDocs]#