Exchange the values of two optionals.
Synopsis
Declared in <bslstl_optional.h>
void
swap(Optional_Base& other) noexcept(/* see-below */);
Description
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.
Exception specification
This function is potentially-throwing unless bsl::is_nothrow_move_constructible<t_TYPE>::value && bsl::is_nothrow_swappable<t_TYPE>::value.
Parameters
Name |
Description |
other |
optional with which to exchange values |
Created with MrDocs