|
constexpr | Result () noexcept |
| Construct a new Result with a "void" value. More...
|
|
constexpr | Result (const E &e) noexcept |
| Construct a new Result from the specified error (given as lvalue) More...
|
|
constexpr | Result (E &&e) noexcept |
| Construct a new Result from the specified error (given as rvalue) More...
|
|
| Result (const Result &other)=default |
| Copy-construct a new Result from another instance. More...
|
|
Result & | operator= (const Result &other)=default |
| Copy-assign another Result to this instance. More...
|
|
| Result (Result &&other) noexcept(std::is_nothrow_move_constructible< E >::value)=default |
| Move-construct a new Result from another instance. More...
|
|
Result & | operator= (Result &&other) noexcept(std::is_nothrow_move_constructible< E >::value &&std::is_nothrow_move_assignable< E >::value)=default |
| Move-assign another Result to this instance. More...
|
|
| ~Result () noexcept |
| Destruct an instance of Result. More...
|
|
void | EmplaceValue () noexcept |
| Put a new value into this instance, constructed in-place from the given arguments. More...
|
|
template<typename... Args> |
void | EmplaceError (Args &&...args) noexcept |
| Put a new error into this instance, constructed in-place from the given arguments. More...
|
|
bool | HasValue () const noexcept |
| Check whether *this contains a value. More...
|
|
| operator bool () const noexcept |
| Check whether *this contains a value. More...
|
|
const E & | Error () const &noexcept |
| Access the contained error. More...
|
|
E && | Error () &&noexcept |
| Access the contained error. More...
|
|
std::optional< E > | Err () const &noexcept |
| Return the contained error as an Optional. More...
|
|
std::optional< E > | Err () &&noexcept |
| Return the contained error as an Optional. More...
|
|
template<typename F , typename E2 = std::invoke_result_t<F, E>> |
Result< void, E2 > | MapError (F &&fn) |
| Returns the result of the given function on the contained value if it exists; otherwise, returns the result itself. More...
|
|
template<typename F , typename E2 = std::invoke_result_t<F, E>> |
Result< void, E2 > | CheckError (F &&fn) |
| Returns the result of the given function on the contained value if it exists; otherwise, returns the result itself. More...
|
|
template<typename F > |
Result | AndThen (F &&fn) &&noexcept |
| Returns the result of the given function on the contained value if it exists; otherwise, returns the result itself. More...
|
|
template<typename F > |
Result | OrElse (F &&fn) &&noexcept |
| Returns the result itself if it contains a value; otherwise, returns the result of the given function on the error value. More...
|
|
template<typename G > |
E | ErrorOr (G &&defaultError) const &noexcept |
| Return the contained error or the given default error. More...
|
|
template<typename G > |
E | ErrorOr (G &&defaultError) &&noexcept |
| Return the contained error or the given default error. More...
|
|
template<typename F > |
void | Resolve (F &&f) const |
| Do nothing or call a function. More...
|
|
template<typename E>
class core_type::Result< void, E >
Specialization of class Result for "void" values.
This class is implemented based on API specification of ara::core::Result from Adaptive Platform Core AUTOSAR AP R21-11
- Template Parameters
-
Definition at line 453 of file result.h.
template<typename E >
template<typename F , typename E2 = std::invoke_result_t<F, E>>
template<typename E >
template<typename G >
Return the contained error or the given default error.
If *this contains an error, it is returned. Otherwise, the specified default error is returned, static_cast’d to E
- Template Parameters
-
G | The type of defaultError |
- Parameters
-
[in] | defaultError | The error to use if *this does not contain an error |
- Returns
- E The error
Definition at line 720 of file result.h.
721 return !
HasValue() ?
Result{std::move(*
this)} :
static_cast<E
>(defaultError);
References core_type::Result< T, E >::HasValue().
template<typename E >
template<typename G >
Return the contained error or the given default error.
If *this contains an error, it is returned. Otherwise, the specified default error is returned, static_cast’d to E
- Template Parameters
-
G | The type of defaultError |
- Parameters
-
[in] | defaultError | The error to use if *this does not contain an error |
- Returns
- E The error
Definition at line 705 of file result.h.
706 return !
HasValue() ?
Result{*
this} :
static_cast<E
>(defaultError);
References core_type::Result< T, E >::HasValue().
template<typename E >
template<typename... Args>
Build a new Result from an error that is constructed in-place from the given arguments.
This function shall not participate in overload resolution unless: std::is_const Args&&...>::value is true, and the first type of the expanded parameter pack first type of the expanded parameter pack is not a specialization of Result
- Template Parameters
-
Args | The types of arguments given to this function |
- Parameters
-
[in] | args | The arguments used for constructing the error |
- Returns
- Result A Result that contains an error
Definition at line 503 of file result.h.
504 return Result{std::forward<Args>(args)...};
template<typename E >
template<typename F , typename E2 = std::invoke_result_t<F, E>>
template<typename E >
template<typename F >
Do nothing or call a function.
If *this contains a value, this function does nothing. Otherwise, the specified callable is invoked. The Callable is expected to be compatible to this interface: void f(const E&);
- Template Parameters
-
F | The type of the Callable f |
- Parameters
-
- Returns
- T The value
Definition at line 736 of file result.h.
References core_type::Result< T, E >::Error().