std::expected<T,E>::operator=

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

# Example

This section is incompleteReason: no example

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
LWG 4025C++23overload (7) was defined as deleted if E is notmove constructible or not move assignableit does not participate inoverload resolution in this case

# See also

-03 · Pages: 6276