[#bsl-swap-04d] = xref:bsl.adoc[bsl]::swap :relfileprefix: ../ :mrdocs: Exchange the values of two optionals. == Synopsis Declared in `<bslstl_optional.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class t_TYPE> void swap( xref:bsl/optional-072.adoc[bsl::optional<t_TYPE>]& lhs, xref:bsl/optional-072.adoc[bsl::optional<t_TYPE>]& rhs) requires BloombergLP::bslma::UsesBslmaAllocator<t_TYPE>::value; ---- == Description Efficiently exchange the values of the specified `lhs` and `rhs` objects. This method provides the no‐throw exception‐safety guarantee if the template parameter `t_TYPE` provides that guarantee, `lhs` and `rhs` have equal allocators, and `lhs.hasValue() == rhs.hasValue()`. == Parameters [cols="1,4"] |=== | Name| Description | *lhs* | left‐hand operand | *rhs* | right‐hand operand |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#