Exchange the values of two optionals.

Synopsis

Declared in <bslstl_optional.h>

template<class t_TYPE>
constexpr
void
swap(
    bsl::optional<t_TYPE>& lhs,
    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 and the result of the hasValue method for lhs and rhs is the same.

Parameters

Name

Description

lhs

left‐hand operand

rhs

right‐hand operand

Created with MrDocs