[#BloombergLP-bslstl-Optional_Base-05-swap] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslstl.adoc[bslstl]::xref:BloombergLP/bslstl/Optional_Base-05.adoc[Optional_Base]::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 template parameter `t_TYPE` provides that guarantee and the result of the `hasValue` method for the two objects being swapped is the same. The behavior is undefined unless this object was created with the same allocator as `other`. == Synopsis Declared in `<bslstl_optional.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- void swap(xref:BloombergLP/bslstl/Optional_Base-05.adoc[Optional_Base]& other) noexcept(/* see-below */); ---- == Exception specification This function is potentially-throwing unless `bsl::is_nothrow_move_constructible<t_TYPE>::value && bsl::is_nothrow_swappable<t_TYPE>::value`. [.small]#Created with https://www.mrdocs.com[MrDocs]#