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

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
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 parameter returning failure_type<std::decay_t<T>>, the other taking two parameters 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 01, 2019 at 23:42:52 UTC


Prev Up HomeNext