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

BOOST_OUTCOME_TRY_FAILURE_LIKELY(var, expr)

Evaluate an expression which results in a type matching the following customisation points, assigning T to a decl called var if successful, immediately returning try_operation_return_as(X) from the calling function if unsuccessful:

Default overloads for these customisation points are provided. See the recipe for supporting foreign input to BOOST_OUTCOME_TRY.

Hints are given to the compiler that the expression will be unsuccessful. If you expect success, you should use BOOST_OUTCOME_TRY(var, expr) instead.

An internal temporary to hold the value of the expression is created, which generally invokes a copy/move. If you wish to never copy/move, you can tell this macro to create the internal temporary as a reference instead.

Overridable: Not overridable.

Definition: See BOOST_OUTCOME_TRYV(expr) for most of the mechanics.

If successful, var is initialised or assigned to the expression result’s .assume_value() if available, else to its .value(). This binds a reference possibly to the T stored inside the bound result of the expression, but possibly also to a temporary emitted from the value observer function.

Header: <boost/outcome/try.hpp>

Legacy: Before Outcome v2.2, var was always declared as an automatic rvalue ref. You can use the backwards compatibility macro OUTCOME21_CO_TRY() if wish to retain the old behaviour.

Last revised: February 12, 2021 at 20:25:43 UTC


Prev Up HomeNext