std::expected<T,E>::operator=
Min standard notice:
Assigns a new value to an existing expected object.
# Declarations
Primary template
constexpr expected& operator=( const expected& other );
(since C++23)
constexpr expected& operator=( expected&& other )
noexcept(/* see below */);
(since C++23)
template< class U = T >
constexpr expected& operator=( U&& v );
(since C++23)
template< class G >
constexpr expected& operator=( const std::unexpected<G>& e );
(since C++23)
template< class G >
constexpr expected& operator=( std::unexpected<G>&& e );
(since C++23)
void partial specialization
constexpr expected& operator=( const expected& other );
(since C++23)
constexpr expected& operator=( expected&& other )
noexcept(/* see below */);
(since C++23)
template< class G >
constexpr expected& operator=( const std::unexpected<G>& e );
(since C++23)
template< class G >
constexpr expected& operator=( std::unexpected<G>&& e );
(since C++23)
Helper function template
template< class T, class U, class... Args >
constexpr void reinit-expected( T& newval, U& oldval, Args&&... args )
(since C++23) (exposition only*)
# Parameters
other: another expected object whose contained value to assignv: value to assign to the contained valuee: std::unexpected object whose contained value to assignnewval: the contained value to be constructedoldval: the contained value to be destroyedargs: the arguments used as initializers of newval
# Example
This section is incompleteReason: no example
# Defect reports
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 4025 | C++23 | overload (7) was defined as deleted if E is notmove constructible or not move assignable | it does not participate inoverload resolution in this case |