OUTCOME_TRY(var, expr)

Evaluate an expression which results in a type matching the following customisation points, assigning T to a variable 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 OUTCOME_TRY.

Hints are given to the compiler that the expression will be successful. If you expect failure, you should use OUTCOME_TRY_FAILURE_LIKELY(var, expr) instead.

Overridable: Not overridable.

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

If successful, an auto &&var is initialised 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: <outcome/try.hpp>