Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / outcome / doc / src / content / reference / macros / tryv_failure_likely.md
1 +++
2 title = "`BOOST_OUTCOME_TRYV_FAILURE_LIKELY(expr)/BOOST_OUTCOME_TRY_FAILURE_LIKELY(expr)`"
3 description = "Evaluate an expression which results in an understood type, continuing execution if successful, immediately returning `try_operation_return_as(X)` from the calling function if unsuccessful."
4 +++
5
6 Evaluate an expression which results in a type matching the following customisation points, continuing execution if successful, immediately returning {{% api "try_operation_return_as(X)" %}} from the calling function if unsuccessful:
7
8 - `BOOST_OUTCOME_V2_NAMESPACE::`{{% api "try_operation_has_value(X)" %}}
9 - `BOOST_OUTCOME_V2_NAMESPACE::`{{% api "try_operation_return_as(X)" %}}
10 - `BOOST_OUTCOME_V2_NAMESPACE::`{{% api "try_operation_extract_value(X)" %}}
11
12 Default overloads for these customisation points are provided. See [the recipe for supporting foreign input to `BOOST_OUTCOME_TRY`]({{% relref "/recipes/foreign-try" %}}).
13
14 The difference between the `BOOST_OUTCOME_TRYV(expr)` and `BOOST_OUTCOME_TRY(expr)` editions is that the latter will set a variable if two or more macro arguments are present (see {{% api "BOOST_OUTCOME_TRY(var, expr)" %}}). The former requires the `T` to be `void`.
15
16 Hints are given to the compiler that the expression will be unsuccessful. If you expect success, you should use {{% api "BOOST_OUTCOME_TRYV(expr)" %}} instead.
17
18 *Overridable*: Not overridable.
19
20 *Definition*: Firstly the expression's temporary is bound to a uniquely named, stack allocated, `auto &&`. If that reference's bound object's `try_operation_has_value()` is false, immediately execute `return try_operation_return_as(propagated unique reference);`, propagating the rvalue/lvalue/etc-ness of the original expression.
21
22 *Header*: `<boost/outcome/try.hpp>`