`try.hpp`

```
namespace outcome_v2_xxx
{
template <class T>
auto try_operation_return_as(T&& v);
}
#define OUTCOME_TRYV(...)
#define OUTCOME_TRYX(...)
#define OUTCOME_TRY(v,...)
```

`outcome_v2_xxx::try_operation_return_as`

```
template <class T>
auto try_operation_return_as(T&& v);
```

Customisation point for changing what the `OUTCOME_TRY`

macros do. This function defaults to returning `std::forward<T>(v).as_failure()`

.

*Effects:* Extracts any state apart from value into a `failure_type`

.

*Requires:* The input value to have a `.as_failure()`

member function.

`OUTCOME_TRYV`

```
#define OUTCOME_TRYV(...) OUTCOME_TRYV2(OUTCOME_TRY_UNIQUE_NAME, __VA_ARGS__)
```

If the outcome returned by expression … is not valued, propagate any failure by immediately returning that failure state immediately

`OUTCOME_TRYX`

```
#define OUTCOME_TRYX(...) ({ auto &&res = (__VA_ARGS__); if(!res.has_value()) return OUTCOME_V2_NAMESPACE::try_operation_return_as(std::forward<decltype(res)>(res)); std::forward<decltype(res)>(res).value(); })
```

If the outcome returned by expression … is not valued, propagate any failure by immediately returning that failure state immediately, else become the unwrapped value as an expression. This makes `OUTCOME_TRYX(expr)`

an expression which can be used exactly like the `try`

operator in other languages.

*Note:** This macro makes use of a proprietary extension in GCC and clang and is not portable. The macro is not made available on unsupported compilers, so you can test for its presence using `#ifdef OUTCOME_TRYX`

.

`OUTCOME_TRY`

```
#define OUTCOME_TRY(v,...) OUTCOME_TRY2(OUTCOME_TRY_UNIQUE_NAME, v, __VA_ARGS__)
```

If the outcome returned by expression … is not valued, propagate any failure by immediately returning that failure immediately, else set *v* to the unwrapped value.