Namespaces
Variants
Views
Actions

swap(std::expected)

From cppreference.com
< cpp‎ | utility‎ | expected
 
 
Utilities library
General utilities
Date and time
Function objects
Formatting library (C++20)
(C++11)
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)(C++20)(C++20)   
(C++20)
Swap and type operations
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)
(C++23)
Elementary string conversions
(C++17)
(C++17)
 
 
friend constexpr void swap( expected& lhs, expected& rhs ) noexcept(/*see below*/);
(since C++23)

Overloads the std::swap algorithm for std::expected. Exchanges the state of lhs with that of rhs. Effectively calls lhs.swap(rhs).

This overload participates in overload resolution only if lhs.swap(rhs) is valid.

This function is not visible to ordinary unqualified or qualified lookup, and can only be found by argument-dependent lookup when std::expected<T, E> is an associated class of the arguments.

Contents

[edit] Parameters

lhs, rhs - expected objects whose states to swap

[edit] Return value

(none)

[edit] Exceptions

noexcept specification:  
noexcept(noexcept(lhs.swap(rhs)))

[edit] Example

[edit] See also

(C++23)
exchanges the contents
(public member function) [edit]