Inherits resilient::detail::Variant< Types >.
|
(Note that these are not member functions.)
|
| template<typename Value , typename Failure > |
| bool | holds_failure (const Failable< Value, Failure > &failable) |
| | Check whether the Failable contains a failure. More...
|
| |
| template<typename Value , typename Failure > |
| bool | holds_value (const Failable< Value, Failure > &failable) |
| | Check whether the Failable contains a value. More...
|
| |
| template<typename Failable , if_is_failable< Failable > = nullptr> |
| auto | get_failure (Failable &&failable) -> detail::same_const_ref_as_t< Failable, detail::failable_failure_type_t< Failable >> |
| | Get the failure in the Failable. More...
|
| |
| template<typename Failable , if_is_failable< Failable > = nullptr> |
| auto | get_value (Failable &&failable) -> detail::same_const_ref_as_t< Failable, detail::failable_value_type_t< Failable >> |
| | Get the value in the Failable. More...
|
| |
| template<typename Failable , if_is_failable< Failable > = nullptr> |
| auto | get_value_or (Failable &&failable, detail::get_value_return_type< Failable > default_value) -> detail::get_value_return_type< Failable > |
| | Get the value in the Failable or default_value if not present. More...
|
| |
| template<typename Failable , typename OtherFailable , if_is_failable< Failable > = nullptr, if_is_failable< OtherFailable > = nullptr> |
| auto | get_value_or (Failable &&failable, OtherFailable &&other) -> std::remove_const_t< std::remove_reference_t< OtherFailable >> |
| | Get the combination of two Failables sharing the same value_type. More...
|
| |
| template<typename Failable , typename Invocable , typename InvocableResult = detail::invoke_result_t<Invocable>, if_is_failable< Failable > = nullptr, detail::if_is_convertible_to_get_value_return_type_of< Failable, InvocableResult > = nullptr> |
| auto | get_value_or_invoke (Failable &&failable, Invocable &&invocable) -> detail::get_value_return_type< Failable > |
| | Get the value in failable if it holds a value, the returned value of invoking invocable otherwise. More...
|
| |
| template<typename Failable , typename Invocable , typename InvocableResult = detail::invoke_result_t<Invocable>, if_is_failable< Failable > = nullptr, if_is_failable< InvocableResult > = nullptr> |
| auto | get_value_or_invoke (Failable &&failable, Invocable &&invocable) -> std::remove_const_t< std::remove_reference_t< InvocableResult >> |
| | Get the combination of failable and the result of invoking invocable. More...
|
| |
| template<typename Visitor , typename Failable , if_is_failable< Failable > = nullptr> |
| | decltype (auto) resilient::visit(Visitor &&visitor, Failable &&failable) |
| | Apply a visitor to the Failable. More...
|
| |
| template<typename Failable , typename Failure > |
| Failable | from_failure (Failure &&failure) |
| | Create a Failable with a failure type. More...
|
| |
| template<typename Failable , typename OtherFailable > |
| Failable | from_narrower_failable (OtherFailable &&failable) |
| | Construct a Failable from another Failable with the same value_type and a narrower failure_type. More...
|
| |
template<typename Value, typename Failure>
class resilient::Failable< Value, Failure >
A class to represent the result of an operation which might fail.
A Failable is either a value or a failure. The value is the return value of the invoked function, the failure is an object representing the failure which happened.
- Template Parameters
-
| Value | The value. |
| Failure | The type of the failure. |
template<typename Failable , typename Invocable , typename InvocableResult = detail::invoke_result_t<Invocable>, if_is_failable< Failable > = nullptr, detail::if_is_convertible_to_get_value_return_type_of< Failable, InvocableResult > = nullptr>
| auto get_value_or_invoke |
( |
Failable< Value, Failure > && |
failable, |
|
|
Invocable && |
invocable |
|
) |
| -> detail::get_value_return_type<Failable>
|
|
related |
Get the value in failable if it holds a value, the returned value of invoking invocable otherwise.
- See also
- get_value_or()
The function is similar to get_value_or() but allows to compute the default value lazily.
- Parameters
-
| failable | The Failable to get the value from if present. |
| invocable | The object to call if failable does not hold a value. |
- Returns
- The value stored in failable or the value returned by invocable.
template<typename Failable , typename Invocable , typename InvocableResult = detail::invoke_result_t<Invocable>, if_is_failable< Failable > = nullptr, if_is_failable< InvocableResult > = nullptr>
| auto get_value_or_invoke |
( |
Failable< Value, Failure > && |
failable, |
|
|
Invocable && |
invocable |
|
) |
| -> std::remove_const_t<std::remove_reference_t<InvocableResult>>
|
|
related |
Get the combination of failable and the result of invoking invocable.
- See also
- get_value_or
Equivalent to get_value_or() with a Failable which is provided by lazily calling invocable. invocable is only called if failable does not contain a value.
- Parameters
-
| failable | A Failable. |
| invocable | A function which returns a Failable with value_type compatible to the one of failable. |
- Returns
- The combination of
failable and the result of invocable. See get_value_or() for what the result contains.