Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Prev Up HomeNext

auto failure(T &&, ...)

Returns appropriate type sugar for constructing an unsuccessful result or outcome, usually failure_type<EC, EP = void> with a decayed T.

Two default overloads are provided, one taking a single required parameter with optional spare storage value parameter returning failure_type<std::decay_t<T>>, the other taking two required parameters with optional spare storage value parameter returning failure_type<std::decay_t<T>, std::decay_t<U>>. Both overloads perfectly forward their inputs.

Note that failure() overloads are permitted by Outcome to return something other than failure_type. For example, basic_result’s auto as_failure() const & returns whatever type failure() returns, and BOOST_OUTCOME_TRY(var, expr) by default returns for failure whatever .as_failure() returns. This can be useful to have BOOST_OUTCOME_TRY(...} propagate on failure something custom for some specific input basic_result or basic_outcome.

Overridable: By Argument Dependent Lookup (ADL).

Requires: Always available.

Namespace: BOOST_OUTCOME_V2_NAMESPACE

Header: <boost/outcome/success_failure.hpp>

Last revised: February 23, 2021 at 17:37:27 UTC


Prev Up HomeNext