std::expected<T,E>::transform

If *this represents an expected value, invokes f and returns a std::expected object that contains an expected value, which is initialized with its result (or value-initialized if the result type is void). Otherwise, returns a std::expected object that contains an unexpected value, which is initialized with the unexpected value of *this.

# Declarations

Primary template
template< class F >
constexpr auto transform( F&& f ) &;

(since C++23)

template< class F >
constexpr auto transform( F&& f ) const&;

(since C++23)

template< class F >
constexpr auto transform( F&& f ) &&;

(since C++23)

template< class F >
constexpr auto transform( F&& f ) const&&;

(since C++23)

void partial specialization
template< class F >
constexpr auto transform( F&& f ) &;

(since C++23)

template< class F >
constexpr auto transform( F&& f ) const&;

(since C++23)

template< class F >
constexpr auto transform( F&& f ) &&;

(since C++23)

template< class F >
constexpr auto transform( F&& f ) const&&;

(since C++23)

# Parameters

# Return value

Given expression expr as:

# Example

This section is incompleteReason: no example

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
LWG 3938C++23the expected value was obtained by value()[1]changed to **this
LWG 3973C++23the expected value was obtained by **this[2]changed to val

# See also