std::expected<T,E>::transform
Min standard notice:
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
f: a suitable function or Callable object whose call signature returns a non-reference type
# Return value
Given expression expr as:
# Example
This section is incompleteReason: no example
# Defect reports
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 3938 | C++23 | the expected value was obtained by value()[1] | changed to **this |
| LWG 3973 | C++23 | the expected value was obtained by **this[2] | changed to val |