[#beman-optional-optional-03-swap] = xref:beman.adoc[beman]::xref:beman/optional.adoc[optional]::xref:beman/optional/optional-03.adoc[optional]::swap :relfileprefix: ../../../ :mrdocs: Swaps this optional with the other. == Synopsis Declared in `<beman/optional/optional.hpp>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- constexpr void swap(xref:beman/optional/optional-03.adoc[optional]& rhs) noexcept(std::is_nothrow_move_constructible<T>::value && std::is_nothrow_swappable<T>::value); ---- == Description Swaps this optional with the other. If neither optionals have a value, nothing happens. If both have a value, the values are swapped. If one has a value, it is moved to the other and the movee is left valueless. [.small]#Created with https://www.mrdocs.com[MrDocs]#