Unnamed: 0
int64 0
0
| repo_id
stringlengths 5
186
| file_path
stringlengths 15
223
| content
stringlengths 1
32.8M
⌀ |
---|---|---|---|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/explicit_make_error_code_copy_converting_constructor.md | +++
title = "`explicit basic_result(const basic_result<R, S, P> &)`"
description = "Explicit converting copy constructor from compatible `basic_result`. Available if `predicate::enable_make_error_code_compatible_conversion<R, S, P>` is true. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "explicit-constructors", "converting-constructors"]
weight = 321
+++
Explicit converting copy constructor from compatible `basic_result`. Calls {{% api "void on_result_copy_construction(T *, U &&) noexcept" %}} with `this` and the input.
*Requires*: `predicate::enable_make_error_code_compatible_conversion<R, S, P>` is true.
*Complexity*: Same as for the copy constructors of the underlying types. Constexpr, triviality and noexcept of underlying operations is propagated.
*Guarantees*: If an exception is thrown during the operation, the object is left in a partially completed state, as per the normal rules for the same operation on a `struct`.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/implicit_value_converting_constructor.md | +++
title = "`basic_result(R &&)`"
description = "Implicit `value_type` constructor. Available if `predicate::enable_value_converting_constructor<R>` is true. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "implicit-constructors", "converting-constructors"]
weight = 180
+++
Implicit `value_type` constructor. Calls {{% api "void on_result_construction(T *, U &&) noexcept" %}} with `this` and `R`.
*Requires*: `predicate::enable_value_converting_constructor<R>` is true.
*Complexity*: Same as for `value_type`'s copy or move constructor. Constexpr, triviality and noexcept of underlying operations is propagated. |
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/disabling_catchall.md | +++
title = "`basic_result(Args...) = delete`"
description = "Disabling catchall constructor used to give useful diagnostic error when trying to use non-inplace constructors when `predicate::constructors_enabled` is false."
categories = ["constructors", "disabling-constructors"]
weight = 160
+++
Disabling catchall constructor used to give useful diagnostic error when trying to use non-inplace constructors when `predicate::constructors_enabled` is false.
*Requires*: `predicate::constructors_enabled` is false.
*Complexity*: N/A. |
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/move_assignment.md | +++
title = "`basic_result &operator=(basic_result &&)`"
description = "Move assignment. Constexpr, triviality and noexcept propagating."
categories = ["operators", "assignment", "move-assignment"]
weight = 130
+++
Move assignment.
*Requires*: that `value_type` and `error_type` both implement move assignment.
*Complexity*: If the `value_type` for both is present, uses `value_type`'s move assignment operator, else either destructs or move constructs `value_type` as appropriate. `error_type`'s move assignment operator is always used. Constexpr, triviality and noexcept of underlying operations is propagated.
*Guarantees*: If an exception is thrown during the operation, the object is left in a partially completed state, as per the normal rules for the same operation on a `struct`.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/implicit_success_move_constructor.md | +++
title = "`basic_result(success_type<T> &&)`"
description = "Implicit value-from-success-type-sugar move constructor. Available if `predicate::enable_compatible_conversion<T, void, void>` is true, or `T` is `void`. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "implicit-constructors", "tagged-constructors"]
weight = 510
+++
Implicit value-from-success-type-sugar move constructor used to disambiguate the construction of the value type.
Note that if `T = void`, `value_type` will be default constructed. Calls {{% api "void on_result_move_construction(T *, U &&) noexcept" %}} with `this` and `success_type<T> &&`.
*Requires*: `predicate::enable_compatible_conversion<T, void, void>` is true, or `T` is `void`.
*Complexity*: Same as for the `value_type` constructor which accepts `T`, or the `value_type` default constructor if `T` is `void`. Constexpr, triviality and noexcept of underlying operations is propagated. |
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/value_lvalue_const.md | +++
title = "`const value_type &value() const &`"
description = "Wide contract const lvalue reference observer of any value present. Constexpr propagating."
categories = ["observers"]
weight = 650
+++
Wide contract const lvalue reference observer of any value present. `NoValuePolicy::wide_value_check()` is first invoked, then the reference to the value is returned.
Note that if `value_type` is `void`, only a `const` overload returning `void` is present.
*Requires*: Always available.
*Complexity*: Depends on `NoValuePolicy::wide_value_check()`.
*Guarantees*: None.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/explicit_inplace_value_constructor_il.md | +++
title = "`explicit basic_result(in_place_type_t<value_type_if_enabled>, std::initializer_list<U>, Args ...)`"
description = "Explicit inplace value constructor. Available if `predicate::enable_inplace_value_constructor<std::initializer_list<U>, Args ...>` is true. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "explicit-constructors", "inplace-constructors"]
weight = 410
+++
Explicit inplace value constructor. Calls {{% api "void on_result_in_place_construction(T *, in_place_type_t<U>, Args &&...) noexcept" %}} with `this`, `in_place_type<value_type>`, 'std::initializer_list<U>' and `Args ...`.
*Requires*: `predicate::enable_inplace_value_constructor<std::initializer_list<U>, Args ...>` is true.
*Complexity*: Same as for the `value_type` constructor which accepts `std::initializer_list<U>, Args ...`. Constexpr, triviality and noexcept of underlying operations is propagated.
*Guarantees*: If an exception is thrown during the operation, the state of the Args is left indeterminate.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/explicit_inplace_error_constructor.md | +++
title = "`explicit basic_result(in_place_type_t<error_type_if_enabled>, Args ...)`"
description = "Explicit inplace error constructor. Available if `predicate::enable_inplace_error_constructor<Args ...>` is true. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "explicit-constructors", "inplace-constructors"]
weight = 420
+++
Explicit inplace error constructor. Calls {{% api "void on_result_in_place_construction(T *, in_place_type_t<U>, Args &&...) noexcept" %}} with `this`, `in_place_type<error_type>` and `Args ...`.
*Requires*: `predicate::enable_inplace_error_constructor<Args ...>` is true.
*Complexity*: Same as for the `error_type` constructor which accepts `Args ...`. Constexpr, triviality and noexcept of underlying operations is propagated.
*Guarantees*: If an exception is thrown during the operation, the state of the Args is left indeterminate.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/implicit_failure_make_error_code_copy_constructor.md | +++
title = "`basic_result(const failure_type<T> &)`"
description = "Implicit error-from-failure-type-sugar copy constructor. Available if `predicate::enable_make_error_code_compatible_conversion<void, T, void>` is true, or `T` is `void`. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "implicit-constructors", "tagged-constructors"]
weight = 531
+++
Implicit error-from-failure-type-sugar copy constructor used to disambiguate the construction of the error type.
Note that if `T = void`, `error_type` will be default constructed. Calls {{% api "void on_result_copy_construction(T *, U &&) noexcept" %}} with `this` and `const failure_type<T> &`.
*Requires*: `predicate::enable_make_error_code_compatible_conversion<void, T, void>` is true, or `T` is `void`.
*Complexity*: Same as for the `error_type` constructor which accepts `T`, or the `error_type` default constructor if `T` is `void`. Constexpr, triviality and noexcept of underlying operations is propagated. |
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/_index.md | +++
title = "`basic_result<T, E, NoValuePolicy>`"
description = "A sum type carrying either a successful `T`, or a disappointment `E`, with `NoValuePolicy` specifying what to do if one tries to read state which isn't there."
+++
A sum type carrying either a `T` or an `E`, with `NoValuePolicy` specifying what to do if one tries to read state which isn't there, and enabling injection of hooks to trap when lifecycle events occur. Either or both of `T` and `E` can be `void` to indicate no value for that state is present. Note that `E = void` makes basic result into effectively an `optional<T>`, but with `NoValuePolicy` configurable behaviour. Detectable using {{% api "is_basic_result<T>" %}}.
*Requires*: Concept requirements if C++ 20, else static asserted:
- That trait {{% api "type_can_be_used_in_basic_result<R>" %}} is true for both `T` and `E`.
- That either `E` is `void` or `DefaultConstructible` (Outcome v2.1 and earlier only).
*Namespace*: `OUTCOME_V2_NAMESPACE`
*Header*: `<outcome/basic_result.hpp>`
*Inclusions*: The very lightest weight of C and C++ header files:
1. `<cstdint>`
2. `<initializer_list>`
3. `<iosfwd>`
4. `<new>`
5. `<type_traits>`
6. If {{% api "OUTCOME_USE_STD_IN_PLACE_TYPE" %}} is `1`, `<utility>` (defaults to `1` for C++ 17 or later only)
7. If C++ exceptions disabled and `OUTCOME_DISABLE_EXECINFO` undefined only (used to print stack backtraces on "exception throw"):
1. `<sal.h>` (Windows only)
2. `<stddef.h>` (Windows only)
3. `<string.h>` (Windows only)
4. `<execinfo.h>` (POSIX only)
8. `<cstdio>`
9. `<cstdlib>`
10. `<cassert>`
This very light weight set of inclusion dependencies makes basic result suitable for use in global header files of very large C++ codebases.
### Design rationale
The basic result type is the main workhorse type of the Outcome library, providing a simple sum type with optional values representing success or disappointment. Unlike {{% api "std::expected<T, E>" %}}, Outcome's result type is designed specifically for convenience when implementing failure handling across very large codebases, and it has a number of API differences to facilitate that.
The first major design difference is that basic result models its constructor design on {{% api "std::variant<...>" %}}, rather than modelling {{% api "std::optional<T>" %}}'s constructor design like `std::expected<T, E>` does. This means that basic result will implicitly construct either a `T` or an `E` if doing so is unambiguous, same as `variant` does. Where implicit construction is ambiguous, the implicit constructors disable and a `T` or `E` can be specified via {{% api "in_place_type_t<T>" %}}, or via {{% api "success_type<T>" %}} or {{% api "failure_type<T>" %}}. We implement a subset of variant's constructors for improved compile time impact, so the implicit and explicit constructor design is split into fixed subsets to reduce SFINAE execution.
The second major design difference is that union storage is ONLY used when both `T` and `E` are trivially copyable or `void`, otherwise struct storage is used. This is usually not a problem, as it is assumed that `sizeof(E)` will be small for failure handling. The choice to only use union storage for trivially copyable types only very considerably reduces load on the compiler, and substantially improves compile times in very large C++ 14 codebases, because copies and moves do not need to jump through complex ceremony in order to implement the never-empty guarantees which would be required in a union storage based implementation (C++ 17 onwards does far fewer copy and move constructor instantiations, but it all adds up -- work avoided is always the fastest).
### Public member type aliases
- `value_type` is `T`.
- `error_type` is `E`.
- `no_value_policy_type` is `NoValuePolicy`.
- `value_type_if_enabled` is `T` if construction from `T` is available, else it is a usefully named unusable internal type.
- `error_type_if_enabled` is `E` if construction from `E` is available, else it is a usefully named unusable internal type.
- `rebind<A, B = E, C = NoValuePolicy>` is `basic_result<A, B, C>`.
### Protected member predicate booleans
- `predicate::constructors_enabled` is constexpr boolean true if decayed `value_type` and decayed `error_type` are not the same type.
- `predicate::implicit_constructors_enabled` is constexpr boolean true if:
1. `predicate::constructors_enabled` is true.
2. Trait {{% api "is_error_type<E>" %}} is not true for both decayed `value_type` and decayed `error_type` at the same time.
3. `value_type` is not implicitly constructible from `error_type` and `error_type` is not implicitly constructible from `value_type`.<br>OR<br>trait {{% api "is_error_type<E>" %}} is true for decayed `error_type` and `error_type` is not implicitly constructible from `value_type` and `value_type` is an integral type.
- `predicate::enable_value_converting_constructor<A>` is constexpr boolean true if:
1. `predicate::constructors_enabled` is true.
2. Decayed `A` is not this `basic_result` type.
3. `predicate::implicit_constructors_enabled` is true.
4. Decayed `A` is not an `in_place_type_t`.
5. Trait {{% api "is_error_type_enum<E, Enum>" %}} is false for `error_type` and decayed `A`.
6. `value_type` is implicitly constructible from `A` and `error_type` is not implicitly constructible from `A`.<br>OR<br>`value_type` is the exact same type as decayed `A` and `value_type` is implicitly constructible from `A`.
- `predicate::enable_error_converting_constructor<A>` is constexpr boolean true if:
1. `predicate::constructors_enabled` is true.
2. Decayed `A` is not this `basic_result` type.
3. `predicate::implicit_constructors_enabled` is true.
4. Decayed `A` is not an `in_place_type_t`.
5. Trait {{% api "is_error_type_enum<E, Enum>" %}} is false for `error_type` and decayed `A`.
6. `value_type` is not implicitly constructible from `A` and `error_type` is implicitly constructible from `A`.<br>OR<br>`error_type` is the exact same type as decayed `A` and `error_type` is implicitly constructible from `A`.
- `predicate::enable_error_condition_converting_constructor<ErrorCondEnum>` is constexpr boolean true if:
1. `predicate::constructors_enabled` is true.
2. Decayed `ErrorCondEnum` is not this `basic_result` type.
3. Decayed `ErrorCondEnum` is not an `in_place_type_t`.
4. Trait {{% api "is_error_type_enum<E, Enum>" %}} is true for `error_type` and decayed `ErrorCondEnum`.
- `predicate::enable_compatible_conversion<A, B, C>` is constexpr boolean true if:
1. `predicate::constructors_enabled` is true.
2. `basic_result<A, B, C>` is not this `basic_result` type.
3. `A` is `void` OR `value_type` is explicitly constructible from `A`.
4. `B` is `void` OR `error_type` is explicitly constructible from `B`.
- `predicate::enable_make_error_code_compatible_conversion<A, B, C>` is constexpr boolean true if:
1. `predicate::constructors_enabled` is true.
2. `basic_result<A, B, C>` is not this `basic_result` type.
3. Trait {{% api "is_error_code_available<T>" %}} is true for decayed `error_type`.
4. `predicate::enable_compatible_conversion<A, B, C>` is not true.
5. `A` is `void` OR `value_type` is explicitly constructible from `A`.
6. `error_type` is explicitly constructible from `make_error_code(B)`.
- `predicate::enable_make_exception_ptr_compatible_conversion<A, B, C>` is constexpr boolean true if:
1. `predicate::constructors_enabled` is true.
2. `basic_result<A, B, C>` is not this `basic_result` type.
3. Trait {{% api "is_exception_ptr_available<T>" %}} is true for decayed `error_type`.
4. `predicate::enable_compatible_conversion<A, B, C>` is not true.
5. `A` is `void` OR `value_type` is explicitly constructible from `A`.
6. `error_type` is explicitly constructible from `make_exception_ptr(B)`.
- `predicate::enable_inplace_value_constructor<Args...>` is constexpr boolean true if:
1. `predicate::constructors_enabled` is true.
2. `value_type` is `void` OR `value_type` is explicitly constructible from `Args...`.
- `predicate::enable_inplace_error_constructor<Args...>` is constexpr boolean true if:
1. `predicate::constructors_enabled` is true.
2. `error_type` is `void` OR `error_type` is explicitly constructible from `Args...`.
- `predicate::enable_inplace_value_error_constructor<Args...>` is constexpr boolean true if:
1. `predicate::constructors_enabled` is true.
2. `predicate::implicit_constructors_enabled` is true.
3. Either, but not both, of `value_type` is explicitly constructible from `Args...` or `error_type` is explicitly constructible from `Args...`.
#### Summary of [standard requirements provided](https://en.cppreference.com/w/cpp/named_req)
- ~~`DefaultConstructible`~~, always deleted to force user to choose valued or errored for every result instanced.
- `MoveConstructible`, if both `value_type` and `error_type` implement move constructors.
- `CopyConstructible`, if both `value_type` and `error_type` implement copy constructors.
- `MoveAssignable`, if both `value_type` and `error_type` implement move constructors and move assignment.
- `CopyAssignable`, if both `value_type` and `error_type` implement copy constructors and copy assignment.
- `Destructible`.
- `Swappable`, with the strong rather than weak guarantee. See {{% api "void swap(basic_result &)" %}} for more information.
- `TriviallyCopyable`, if both `value_type` and `error_type` are trivially copyable.
- `TrivialType`, if both `value_type` and `error_type` are trivial types.
- `LiteralType`, if both `value_type` and `error_type` are literal types.
- `StandardLayoutType`, if both `value_type` and `error_type` are standard layout types. If so, layout of `basic_result` in C is guaranteed to be one of:
```c++
struct trivially_copyable_result_layout {
union {
value_type value;
error_type error;
};
unsigned int flags;
};
```
... if both `value_type` and `error_type` are `TriviallyCopyable`, otherwise:
```c++
struct non_trivially_copyable_result_layout {
value_type value;
unsigned int flags;
error_type error;
};
```
Obviously, all C compatible C++ types are `TriviallyCopyable`, so if you are passing non-trivially copyable types from C++ to C, you are doing undefined behaviour.
- `EqualityComparable`, if both `value_type` and `error_type` implement equality comparisons with one another.
- ~~`LessThanComparable`~~, not implemented due to availability of implicit conversions from `value_type` and `error_type`, this can cause major surprise (i.e. hard to diagnose bugs), so we don't implement these at all.
- ~~`Hash`~~, not implemented as a generic implementation of a unique hash for non-valued items which are unequal would require a dependency on RTTI being enabled.
Thus `basic_result` meets the `Regular` concept if both `value_type` and `error_type` are `Regular`, except for the lack of a default constructor. Often where one needs a default constructor, wrapping `basic_result` into {{% api "std::optional<T>" %}} will suffice.
### Public member functions
#### Disabling constructors
{{% children description="true" depth="2" categories="disabling-constructors" %}}
#### Copy and move constructors and assignment, and destructor
{{% children description="true" depth="2" categories="default-constructors,copy-constructors,move-constructors,copy-assignment,move-assignment,destructors" %}}
#### Converting constructors
{{% children description="true" depth="2" categories="converting-constructors" %}}
#### Inplace constructors
{{% children description="true" depth="2" categories="inplace-constructors" %}}
#### Tagged constructors
{{% children description="true" depth="2" categories="tagged-constructors" %}}
#### Observers
{{% children description="true" depth="2" categories="observers" %}}
#### Modifiers
{{% children description="true" depth="2" categories="modifiers" %}}
#### Comparisons
See above for why `LessThanComparable` is not implemented.
{{% children description="true" depth="2" categories="comparisons" %}}
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/equality_success_type.md | +++
title = "`bool operator!=(const success_type<A> &) const`"
description = "Returns true if this result does not compare equal to the success type sugar. Constexpr and noexcept propagating."
categories = ["comparisons"]
weight = 850
+++
Returns true if this result is not successful or its value does not compares equal to the value in the success type sugar. Comparison is done using `operator!=` on `value_type` and `A`. If `A` is `void`, this call aliases {{% api "bool has_error() const noexcept" %}}.
*Requires*: `operator!=` must be a valid expression between `value_type` and `A`, or `A` is `void`. If `value_type` is `void`, then so must be `A`.
*Complexity*: Whatever the underlying `operator!=` has. Constexpr and noexcept of underlying operations is propagated.
*Guarantees*: None.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/has_value.md | +++
title = "`bool has_value() const noexcept`"
description = "Returns true if a value is present. Constexpr, never throws."
categories = ["observers"]
weight = 591
+++
Returns true if a value is present. Constexpr where possible. Alias for {{% api "explicit operator bool() const noexcept" %}}.
*Requires*: Always available.
*Complexity*: Constant time.
*Guarantees*: Never throws an exception.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/value_rvalue_const.md | +++
title = "`const value_type &&value() const &&`"
description = "Wide contract const rvalue reference observer of any value present. Constexpr propagating."
categories = ["observers"]
weight = 670
+++
Wide contract const rvalue reference observer of any value present. `NoValuePolicy::wide_value_check()` is first invoked, then the reference to the value is returned.
Note that if `value_type` is `void`, only a `const` overload returning `void` is present.
*Requires*: Always available.
*Complexity*: Depends on `NoValuePolicy::wide_value_check()`.
*Guarantees*: None.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/has_failure.md | +++
title = "`bool has_failure() const noexcept`"
description = "Returns true if there is either an error or an exception. Constexpr, never throws."
categories = ["observers"]
weight = 595
+++
Returns true if there is either an error or an exception. Constexpr where possible.
*Requires*: Always available.
*Complexity*: Constant time.
*Guarantees*: Never throws an exception.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/error_rvalue.md | +++
title = "`error_type &&error() &&`"
description = "Wide contract rvalue reference observer of the stored error. Constexpr propagating."
categories = ["observers"]
weight = 760
+++
Wide contract rvalue reference observer of the stored error. `NoValuePolicy::wide_error_check()` is first invoked, then the reference to the error is returned. As a valid default constructed error is always present, no undefined behaviour occurs if `NoValuePolicy::wide_error_check()` returns.
Note that if `error_type` is `void`, only a `const` overload returning `void` is present.
*Requires*: Always available.
*Complexity*: Depends on `NoValuePolicy::wide_error_check()`.
*Guarantees*: None.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/explicit_make_error_code_move_converting_constructor.md | +++
title = "`explicit basic_result(basic_result<R, S, P> &&)`"
description = "Explicit converting move constructor from compatible `basic_result`. Available if `predicate::enable_make_error_code_compatible_conversion<R, S, P>` is true. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "explicit-constructors", "converting-constructors"]
weight = 322
+++
Explicit converting move constructor from compatible `basic_result`. Calls {{% api "void on_result_move_construction(T *, U &&) noexcept" %}} with `this` and the input.
*Requires*: `predicate::enable_make_error_code_compatible_conversion<R, S, P>` is true.
*Complexity*: Same as for the move constructors of the underlying types. Constexpr, triviality and noexcept of underlying operations is propagated.
*Guarantees*: If an exception is thrown during the operation, the object is left in a partially completed state, as per the normal rules for the same operation on a `struct`.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/explicit_make_exception_ptr_copy_converting_constructor.md | +++
title = "`explicit basic_result(const basic_result<R, S, P> &)`"
description = "Explicit converting copy constructor from compatible `basic_result`. Available if `predicate::enable_make_exception_ptr_compatible_conversion<R, S, P>` is true. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "explicit-constructors", "converting-constructors"]
weight = 323
+++
Explicit converting copy constructor from compatible `basic_result`. Calls {{% api "void on_result_copy_construction(T *, U &&) noexcept" %}} with `this` and the input.
*Requires*: `predicate::enable_make_exception_ptr_compatible_conversion<R, S, P>` is true.
*Complexity*: Same as for the copy constructors of the underlying types. Constexpr, triviality and noexcept of underlying operations is propagated.
*Guarantees*: If an exception is thrown during the operation, the object is left in a partially completed state, as per the normal rules for the same operation on a `struct`.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/assume_value_lvalue.md | +++
title = "`value_type &assume_value() & noexcept`"
description = "Narrow contract lvalue reference observer of any value present. Constexpr propagating, never throws."
categories = ["observers"]
weight = 600
+++
Narrow contract lvalue reference observer of any value present. `NoValuePolicy::narrow_value_check()` is first invoked, then the reference to the value is returned. The convention is that hard undefined behaviour occurs if no value is actually present, however `NoValuePolicy::narrow_value_check()` can do something to avoid that.
Note that if `value_type` is `void`, only a `const` overload returning `void` is present.
*Requires*: Always available.
*Complexity*: Depends on `NoValuePolicy::narrow_value_check()`.
*Guarantees*: An exception is never thrown.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/destructor.md | +++
title = "`~basic_result()`"
description = "Destructor. Constexpr, triviality and noexcept propagating."
categories = ["destructors"]
weight = 150
+++
Destructor.
*Requires*: Always available.
*Complexity*: Same as for `value_type`'s and `error_type`'s destructors. Constexpr, triviality and noexcept of underlying operations is propagated.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/disabling_implicit_constructor.md | +++
title = "`basic_result(X &&) = delete`"
description = "Disabling implicit constructor used to give useful diagnostic error when trying to use implicit constructors when `predicate::implicit_constructors_enabled` is false."
categories = ["constructors", "disabling-constructors"]
weight = 170
+++
Disabling implicit constructor used to give useful diagnostic error when trying to use implicit constructors when `predicate::implicit_constructors_enabled` is false.
*Requires*: `predicate::implicit_constructors_enabled` is false.
*Complexity*: N/A. |
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/implicit_failure_make_exception_ptr_move_constructor.md | +++
title = "`basic_result(failure_type<T> &&)`"
description = "Implicit error-from-failure-type-sugar move constructor. Available if `predicate::enable_make_exception_ptr_compatible_conversion<void, T, void>` is true, or `T` is `void`. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "implicit-constructors", "tagged-constructors"]
weight = 534
+++
Implicit error-from-failure-type-sugar move constructor used to disambiguate the construction of the error type.
Note that if `T = void`, `error_type` will be default constructed. Calls {{% api "void on_result_move_construction(T *, U &&) noexcept" %}} with `this` and `failure_type<T> &&`.
*Requires*: `predicate::enable_make_exception_ptr_compatible_conversion<void, T, void>` is true, or `T` is `void`.
*Complexity*: Same as for the `error_type` constructor which accepts `T`, or the `error_type` default constructor if `T` is `void`. Constexpr, triviality and noexcept of underlying operations is propagated. |
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/equality_failure_type.md | +++
title = "`bool operator==(const failure_type<A, void> &) const`"
description = "Returns true if this result compares equal to the failure type sugar. Constexpr and noexcept propagating."
categories = ["comparisons"]
weight = 820
+++
Returns true if this result is unsuccessful and its error compares equal to the error in the failure type sugar. Comparison is done using `operator==` on `error_type` and `A`. If `A` is `void`, this call aliases {{% api "bool has_error() const noexcept" %}}.
*Requires*: `operator==` must be a valid expression between `error_type` and `A`, or `A` is `void`. If `error_type` is `void`, then so must be `A`.
*Complexity*: Whatever the underlying `operator==` has. Constexpr and noexcept of underlying operations is propagated.
*Guarantees*: None.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/equality_basic_result.md | +++
title = "`bool operator==(const basic_result<A, B, C> &) const`"
description = "Returns true if this result compares equal to the other result. Constexpr and noexcept propagating."
categories = ["comparisons"]
weight = 800
+++
Returns true if this result compares equal to the other result. Comparison is done using `operator==` on either `value_type` or `error_type` if the currently chosen state is the same for both results, otherwise false is returned.
*Requires*: `operator==` must be a valid expression between `value_type` and `A`, and between `error_type` and `B`. If `value_type` is `void`, then so must be `A`; similarly for `error_type` and `B`.
*Complexity*: Whatever the underlying `operator==` have. Constexpr and noexcept of underlying operations is propagated.
*Guarantees*: None.
*Free function alias*: There is a free function `bool operator==(const basic_result<A, B, C> &, const basic_outcome<A, B, C, D> &)` which forwards perfectly to this function, by reversing the operands.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/swap.md | +++
title = "`void swap(basic_result &)`"
description = "Swap one basic_result with another, with the strong guarantee. Noexcept propagating."
categories = ["modifiers"]
weight = 900
+++
Swap one basic_result with another, with the strong guarantee. Constexpr if move constructors and move assignments of `value_type` and `error_type` are noexcept.
*Requires*: Always available.
*Complexity*: If the move constructor and move assignment for `value_type` and `error_type` are noexcept, the complexity is the same as for the `swap()` implementations of the `value_type` and `error_type`. Otherwise, complexity is not preserved, as {{% api "strong_swap(bool &all_good, T &a, T &b)" %}} is used instead of `swap()`. This function defaults to using one move construction and two assignments, and it will attempt extra move assignments in order to restore the state upon entry if a failure occurs.
*Guarantees*: If an exception is thrown during the swap operation, the state of both operands on entry is attempted to be restored, in order to implement the strong guarantee. If that too fails, the flag bits are forced to something consistent such that there can be no simultaneously valued and errored state, or valueless and errorless. The flag {{% api "has_lost_consistency()" %}} becomes true for both operands, which are now likely in an inconsistent state.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/implicit_error_condition_converting_constructor.md | +++
title = "`basic_result(ErrorCondEnum &&)`"
description = "Implicit `error_type` from `ErrorCondEnum` constructor. Available if `predicate::enable_error_condition_converting_constructor<ErrorCondEnum>` is true. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "implicit-constructors", "converting-constructors"]
weight = 200
+++
Implicit `error_type` from `ErrorCondEnum` constructor. Calls {{% api "void on_result_construction(T *, U &&) noexcept" %}} with `this` and `ErrorCondEnum`.
*Requires*: `predicate::enable_error_condition_converting_constructor<R>` is true.
*Complexity*: Same as for `error_type`'s copy or move constructor from the result of `make_error_code(ErrorCondEnum)`. Constexpr, triviality and noexcept of underlying operations is propagated.
*Guarantees*: If an exception is thrown during the operation, the state of the input is left indeterminate.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/error_lvalue.md | +++
title = "`error_type &error() &`"
description = "Wide contract lvalue reference observer of the stored error. Constexpr propagating."
categories = ["observers"]
weight = 740
+++
Wide contract lvalue reference observer of the stored error. `NoValuePolicy::wide_error_check()` is first invoked, then the reference to the error is returned. As a valid default constructed error is always present, no undefined behaviour occurs if `NoValuePolicy::wide_error_check()` returns.
Note that if `error_type` is `void`, only a `const` overload returning `void` is present.
*Requires*: Always available.
*Complexity*: Depends on `NoValuePolicy::wide_error_check()`.
*Guarantees*: None.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/move_constructor.md | +++
title = "`basic_result(basic_result &&)`"
description = "Move constructor. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "implicit-constructors", "move-constructors"]
weight = 110
+++
Move constructor.
*Requires*: that `value_type` and `error_type` both implement a move constructor.
*Complexity*: Same as for `value_type`'s and `error_type`'s move constructors. Constexpr, triviality and noexcept of underlying operations is propagated.
*Guarantees*: If an exception is thrown during the operation, the object is left in a partially completed state, as per the normal rules for the same operation on a `struct`.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/implicit_success_copy_constructor.md | +++
title = "`basic_result(const success_type<T> &)`"
description = "Implicit value-from-success-type-sugar copy constructor. Available if `predicate::enable_compatible_conversion<T, void, void>` is true, or `T` is `void`. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "implicit-constructors", "tagged-constructors"]
weight = 500
+++
Implicit value-from-success-type-sugar copy constructor used to disambiguate the construction of the value type.
Note that if `T = void`, `value_type` will be default constructed. Calls {{% api "void on_result_copy_construction(T *, U &&) noexcept" %}} with `this` and `const success_type<T> &`.
*Requires*: `predicate::enable_compatible_conversion<T, void, void>` is true, or `T` is `void`.
*Complexity*: Same as for the `value_type` constructor which accepts `T`, or the `value_type` default constructor if `T` is `void`. Constexpr, triviality and noexcept of underlying operations is propagated. |
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/explicit_move_converting_constructor.md | +++
title = "`explicit basic_result(basic_result<R, S, P> &&)`"
description = "Explicit converting move constructor from compatible `basic_result`. Available if `predicate::enable_compatible_conversion<R, S, P>` is true. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "explicit-constructors", "converting-constructors"]
weight = 320
+++
Explicit converting move constructor from compatible `basic_result`. Calls {{% api "void on_result_move_construction(T *, U &&) noexcept" %}} with `this` and the input.
*Requires*: `predicate::enable_compatible_conversion<R, S, P>` is true.
*Complexity*: Same as for the move constructors of the underlying types. Constexpr, triviality and noexcept of underlying operations is propagated.
*Guarantees*: If an exception is thrown during the operation, the object is left in a partially completed state, as per the normal rules for the same operation on a `struct`.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/explicit_valueorerror_converting_constructor.md | +++
title = "`explicit basic_result(concepts::value_or_error<T, E> &&)`"
description = "Explicit converting constructor from `concepts::value_or_error<T, E>` concept matching types. Available if `convert::value_or_error<>` permits it. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "explicit-constructors", "converting-constructors"]
weight = 300
+++
Explicit converting constructor from {{% api "concepts::value_or_error<T, E>" %}} concept matching types. Delegates to the `basic_result` move constructor.
*Requires*: `convert::`{{% api "value_or_error<T, U>" %}} has an available call operator, and if the input is a `basic_result` or `basic_outcome`, then `convert::value_or_error<>` has enabled those inputs for that `convert::value_or_error<>` specialisation.
*Complexity*: Same as for the copy or move constructor from the input's `.value()` or `.error()` respectively. Constexpr, triviality and noexcept of underlying operations is propagated.
*Guarantees*: If an exception is thrown during the operation, the object is left in a partially completed state, as per the normal rules for the same operation on a `struct`.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/error_lvalue_const.md | +++
title = "`const error_type &error() const &`"
description = "Wide contract const lvalue reference observer of the stored error. Constexpr propagating."
categories = ["observers"]
weight = 750
+++
Wide contract const lvalue reference observer of the stored error. `NoValuePolicy::wide_error_check()` is first invoked, then the reference to the error is returned. As a valid default constructed error is always present, no undefined behaviour occurs if `NoValuePolicy::wide_error_check()` returns.
Note that if `error_type` is `void`, only a `const` overload returning `void` is present.
*Requires*: Always available.
*Complexity*: Depends on `NoValuePolicy::wide_error_check()`.
*Guarantees*: None.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/explicit_copy_converting_constructor.md | +++
title = "`explicit basic_result(const basic_result<R, S, P> &)`"
description = "Explicit converting copy constructor from compatible `basic_result`. Available if `predicate::enable_compatible_conversion<R, S, P>` is true. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "explicit-constructors", "converting-constructors"]
weight = 310
+++
Explicit converting copy constructor from compatible `basic_result`. Calls {{% api "void on_result_copy_construction(T *, U &&) noexcept" %}} with `this` and the input.
*Requires*: `predicate::enable_compatible_conversion<R, S, P>` is true.
*Complexity*: Same as for the copy constructors of the underlying types. Constexpr, triviality and noexcept of underlying operations is propagated.
*Guarantees*: If an exception is thrown during the operation, the object is left in a partially completed state, as per the normal rules for the same operation on a `struct`.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/implicit_failure_make_error_code_move_constructor.md | +++
title = "`basic_result(failure_type<T> &&)`"
description = "Implicit error-from-failure-type-sugar move constructor. Available if `predicate::enable_make_error_code_compatible_conversion<void, T, void>` is true, or `T` is `void`. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "implicit-constructors", "tagged-constructors"]
weight = 532
+++
Implicit error-from-failure-type-sugar move constructor used to disambiguate the construction of the error type.
Note that if `T = void`, `error_type` will be default constructed. Calls {{% api "void on_result_move_construction(T *, U &&) noexcept" %}} with `this` and `failure_type<T> &&`.
*Requires*: `predicate::enable_make_error_code_compatible_conversion<void, T, void>` is true, or `T` is `void`.
*Complexity*: Same as for the `error_type` constructor which accepts `T`, or the `error_type` default constructor if `T` is `void`. Constexpr, triviality and noexcept of underlying operations is propagated. |
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/explicit_inplace_value_constructor.md | +++
title = "`explicit basic_result(in_place_type_t<value_type_if_enabled>, Args ...)`"
description = "Explicit inplace value constructor. Available if `predicate::enable_inplace_value_constructor<Args ...>` is true. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "explicit-constructors", "inplace-constructors"]
weight = 400
+++
Explicit inplace value constructor. Calls {{% api "void on_result_in_place_construction(T *, in_place_type_t<U>, Args &&...) noexcept" %}} with `this`, `in_place_type<value_type>` and `Args ...`.
*Requires*: `predicate::enable_inplace_value_constructor<Args ...>` is true.
*Complexity*: Same as for the `value_type` constructor which accepts `Args ...`. Constexpr, triviality and noexcept of underlying operations is propagated.
*Guarantees*: If an exception is thrown during the operation, the state of the Args is left indeterminate.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/assume_error_rvalue_const.md | +++
title = "`const error_type &&assume_error() const && noexcept`"
description = "Narrow contract const rvalue reference observer of the stored error. Constexpr propagating, never throws."
categories = ["observers"]
weight = 730
+++
Narrow contract const rvalue reference observer of the stored error. `NoValuePolicy::narrow_error_check()` is first invoked, then the reference to the error is returned. As a valid default constructed error is always present, no undefined behaviour occurs unless `NoValuePolicy::narrow_error_check()` does that.
Note that if `error_type` is `void`, only a `const` overload returning `void` is present.
*Requires*: Always available.
*Complexity*: Depends on `NoValuePolicy::narrow_error_check()`.
*Guarantees*: An exception is never thrown.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/assume_value_rvalue_const.md | +++
title = "`const value_type &&assume_value() const && noexcept`"
description = "Narrow contract const rvalue reference observer of any value present. Constexpr propagating, never throws."
categories = ["observers"]
weight = 630
+++
Narrow contract const rvalue reference observer of any value present. `NoValuePolicy::narrow_value_check()` is first invoked, then the reference to the value is returned. The convention is that hard undefined behaviour occurs if no value is actually present, however `NoValuePolicy::narrow_value_check()` can do something to avoid that.
Note that if `value_type` is `void`, only a `const` overload returning `void` is present.
*Requires*: Always available.
*Complexity*: Depends on `NoValuePolicy::narrow_value_check()`.
*Guarantees*: An exception is never thrown.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/assume_error_lvalue_const.md | +++
title = "`const error_type &assume_error() const & noexcept`"
description = "Narrow contract const lvalue reference observer of the stored error. Constexpr propagating, never throws."
categories = ["observers"]
weight = 710
+++
Narrow contract const lvalue reference observer of the stored error. `NoValuePolicy::narrow_error_check()` is first invoked, then the reference to the error is returned. As a valid default constructed error is always present, no undefined behaviour occurs unless `NoValuePolicy::narrow_error_check()` does that.
Note that if `error_type` is `void`, only a `const` overload returning `void` is present.
*Requires*: Always available.
*Complexity*: Depends on `NoValuePolicy::narrow_error_check()`.
*Guarantees*: An exception is never thrown.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/implicit_inplace_value_error_constructor.md | +++
title = "`basic_result(A1 &&, A2 &&, Args ...)`"
description = "Implicit inplace value or error constructor. Available if `predicate::enable_inplace_value_error_constructor<A1, A2, Args ...>` is true. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "implicit-constructors", "inplace-constructors"]
weight = 440
+++
Implicit inplace value or error constructor. Delegates to an appropriate explicit inplace constructor depending on input.
*Requires*: predicate::enable_inplace_value_error_constructor<A1, A2, Args ...>` is true.
*Complexity*: Same as for the `value_type` or `error_type` constructor which accepts `A1, A2, Args ...`. Constexpr, triviality and noexcept of underlying operations is propagated.
*Guarantees*: If an exception is thrown during the operation, the state of the Args is left indeterminate.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/copy_assignment.md | +++
title = "`basic_result &operator=(const basic_result &)`"
description = "Copy assignment. Constexpr, triviality and noexcept propagating."
categories = ["operators", "assignment", "copy-assignment"]
weight = 140
+++
Copy assignment.
*Requires*: that `value_type` and `error_type` both implement copy assignment.
*Complexity*: If the `value_type` for both is present, uses `value_type`'s copy assignment operator, else either destructs or copy constructs `value_type` as appropriate. `error_type`'s copy assignment operator is always used. Constexpr, triviality and noexcept of underlying operations is propagated.
*Guarantees*: If an exception is thrown during the operation, the object is left in a partially completed state, as per the normal rules for the same operation on a `struct`.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/default.md | +++
title = "`basic_result() = delete`"
description = "The default constructor (disabled)."
categories = ["constructors", "implicit-constructors", "default-constructors"]
weight = 100
+++
The default constructor for basic result is always disabled.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/value_rvalue.md | +++
title = "`value_type &&value() &&`"
description = "Wide contract rvalue reference observer of any value present. Constexpr propagating."
categories = ["observers"]
weight = 660
+++
Wide contract rvalue reference observer of any value present. `NoValuePolicy::wide_value_check()` is first invoked, then the reference to the value is returned.
Note that if `value_type` is `void`, only a `const` overload returning `void` is present.
*Requires*: Always available.
*Complexity*: Depends on `NoValuePolicy::wide_value_check()`.
*Guarantees*: None.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/inequality_basic_result.md | +++
title = "`bool operator!=(const basic_result<A, B, C> &) const`"
description = "Returns true if this result does not compare equal to the other result. Constexpr and noexcept propagating."
categories = ["comparisons"]
weight = 840
+++
Returns true if this result does not compare equal to the other result. Comparison is done using `operator!=` on either `value_type` or `error_type` if the currently chosen state is the same for both results, otherwise true is returned.
*Requires*: `operator!=` must be a valid expression between `value_type` and `A`, and between `error_type` and `B`. If `value_type` is `void`, then so must be `A`; similarly for `error_type` and `B`.
*Complexity*: Whatever the underlying `operator!=` have. Constexpr and noexcept of underlying operations is propagated.
*Guarantees*: None.
*Free function alias*: There is a free function `bool operator!=(const basic_result<A, B, C> &, const basic_outcome<A, B, C, D> &)` which forwards perfectly to this function, by reversing the operands.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/explicit_inplace_error_constructor_il.md | +++
title = "`explicit basic_result(in_place_type_t<error_type_if_enabled>, std::initializer_list<U>, Args ...)`"
description = "Explicit inplace error constructor. Available if `predicate::enable_inplace_error_constructor<std::initializer_list<U>, Args ...>` is true. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "explicit-constructors", "inplace-constructors"]
weight = 430
+++
Explicit inplace error constructor. Calls {{% api "void on_result_in_place_construction(T *, in_place_type_t<U>, Args &&...) noexcept" %}} with `this`, `in_place_type<error_type>`, `std::initializer_list<U>` and `Args ...`.
*Requires*: `predicate::enable_inplace_error_constructor<std::initializer_list<U>, Args ...>` is true.
*Complexity*: Same as for the `error_type` constructor which accepts `std::initializer_list<U>, Args ...`. Constexpr, triviality and noexcept of underlying operations is propagated.
*Guarantees*: If an exception is thrown during the operation, the state of the Args is left indeterminate.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/assume_error_rvalue.md | +++
title = "`error_type &&assume_error() && noexcept`"
description = "Narrow contract rvalue reference observer of the stored error. Constexpr propagating, never throws."
categories = ["observers"]
weight = 720
+++
Narrow contract rvalue reference observer of the stored error. `NoValuePolicy::narrow_error_check()` is first invoked, then the reference to the error is returned. As a valid default constructed error is always present, no undefined behaviour occurs unless `NoValuePolicy::narrow_error_check()` does that.
Note that if `error_type` is `void`, only a `const` overload returning `void` is present.
*Requires*: Always available.
*Complexity*: Depends on `NoValuePolicy::narrow_error_check()`.
*Guarantees*: An exception is never thrown.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/as_failure_rvalue.md | +++
title = "`auto as_failure() &&`"
description = "Return the output from free function `failure()` containing a move of any errored state."
categories = ["modifiers"]
weight = 920
+++
Return the output from free function {{% api "auto failure(T &&, ...)" %}} containing a move from any errored state, thus leaving the result's error value in a moved-from state. Depending on the choice of `error_type`, this function may therefore be destructive. The error state is accessed using {{% api "error_type &&assume_error() && noexcept" %}}.
*Requires*: Always available.
*Complexity*: Whatever that of `error_type`'s move constructor is.
*Guarantees*: None.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/error_rvalue_const.md | +++
title = "`const error_type &&error() const &&`"
description = "Wide contract const rvalue reference observer of the stored error. Constexpr propagating."
categories = ["observers"]
weight = 770
+++
Wide contract const rvalue reference observer of the stored error. `NoValuePolicy::wide_error_check()` is first invoked, then the reference to the error is returned. As a valid default constructed error is always present, no undefined behaviour occurs if `NoValuePolicy::wide_error_check()` returns.
Note that if `error_type` is `void`, only a `const` overload returning `void` is present.
*Requires*: Always available.
*Complexity*: Depends on `NoValuePolicy::wide_error_check()`.
*Guarantees*: None.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/assume_value_lvalue_const.md | +++
title = "`const value_type &assume_value() const & noexcept`"
description = "Narrow contract const lvalue reference observer of any value present. Constexpr propagating, never throws."
categories = ["observers"]
weight = 610
+++
Narrow contract const lvalue reference observer of any value present. `NoValuePolicy::narrow_value_check()` is first invoked, then the reference to the value is returned. The convention is that hard undefined behaviour occurs if no value is actually present, however `NoValuePolicy::narrow_value_check()` can do something to avoid that.
Note that if `value_type` is `void`, only a `const` overload returning `void` is present.
*Requires*: Always available.
*Complexity*: Depends on `NoValuePolicy::narrow_value_check()`.
*Guarantees*: An exception is never thrown.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/implicit_failure_move_constructor.md | +++
title = "`basic_result(failure_type<T> &&)`"
description = "Implicit error-from-failure-type-sugar move constructor. Available if `predicate::enable_compatible_conversion<void, T, void>` is true, or `T` is `void`. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "implicit-constructors", "tagged-constructors"]
weight = 530
+++
Implicit error-from-failure-type-sugar move constructor used to disambiguate the construction of the error type.
Note that if `T = void`, `error_type` will be default constructed. Calls {{% api "void on_result_move_construction(T *, U &&) noexcept" %}} with `this` and `failure_type<T> &&`.
*Requires*: `predicate::enable_compatible_conversion<void, T, void>` is true, or `T` is `void`.
*Complexity*: Same as for the `error_type` constructor which accepts `T`, or the `error_type` default constructor if `T` is `void`. Constexpr, triviality and noexcept of underlying operations is propagated. |
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/implicit_failure_make_exception_ptr_copy_constructor.md | +++
title = "`basic_result(const failure_type<T> &)`"
description = "Implicit error-from-failure-type-sugar copy constructor. Available if `predicate::enable_make_exception_ptr_compatible_conversion<void, T, void>` is true, or `T` is `void`. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "implicit-constructors", "tagged-constructors"]
weight = 533
+++
Implicit error-from-failure-type-sugar copy constructor used to disambiguate the construction of the error type.
Note that if `T = void`, `error_type` will be default constructed. Calls {{% api "void on_result_copy_construction(T *, U &&) noexcept" %}} with `this` and `const failure_type<T> &`.
*Requires*: `predicate::enable_make_exception_ptr_compatible_conversion<void, T, void>` is true, or `T` is `void`.
*Complexity*: Same as for the `error_type` constructor which accepts `T`, or the `error_type` default constructor if `T` is `void`. Constexpr, triviality and noexcept of underlying operations is propagated. |
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/value_lvalue.md | +++
title = "`value_type &value() &`"
description = "Wide contract lvalue reference observer of any value present. Constexpr propagating."
categories = ["observers"]
weight = 640
+++
Wide contract lvalue reference observer of any value present. `NoValuePolicy::wide_value_check()` is first invoked, then the reference to the value is returned.
Note that if `value_type` is `void`, only a `const` overload returning `void` is present.
*Requires*: Always available.
*Complexity*: Depends on `NoValuePolicy::wide_value_check()`.
*Guarantees*: None.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/as_failure_lvalue.md | +++
title = "`auto as_failure() const &`"
description = "Return the output from free function `failure()` containing a copy of any errored state."
categories = ["observers"]
weight = 910
+++
Return the output from free function {{% api "auto failure(T &&, ...)" %}} containing a copy of any errored state. The error state is accessed using {{% api "const error_type &assume_error() const & noexcept" %}}.
*Requires*: Always available.
*Complexity*: Whatever that of `error_type`'s copy constructor is.
*Guarantees*: None.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/explicit_make_exception_ptr_move_converting_constructor.md | +++
title = "`explicit basic_result(basic_result<R, S, P> &&)`"
description = "Explicit converting move constructor from compatible `basic_result`. Available if `predicate::enable_make_exception_ptr_compatible_conversion<R, S, P>` is true. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "explicit-constructors", "converting-constructors"]
weight = 324
+++
Explicit converting move constructor from compatible `basic_result`. Calls {{% api "void on_result_move_construction(T *, U &&) noexcept" %}} with `this` and the input.
*Requires*: `predicate::enable_make_exception_ptr_compatible_conversion<R, S, P>` is true.
*Complexity*: Same as for the move constructors of the underlying types. Constexpr, triviality and noexcept of underlying operations is propagated.
*Guarantees*: If an exception is thrown during the operation, the object is left in a partially completed state, as per the normal rules for the same operation on a `struct`.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/has_error.md | +++
title = "`bool has_error() const noexcept`"
description = "Returns true if an error is present. Constexpr, never throws."
categories = ["observers"]
weight = 592
+++
Returns true if an error is present. Constexpr where possible.
*Requires*: Always available.
*Complexity*: Constant time.
*Guarantees*: Never throws an exception.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/assume_error_lvalue.md | +++
title = "`error_type &assume_error() & noexcept`"
description = "Narrow contract lvalue reference observer of the stored error. Constexpr propagating, never throws."
categories = ["observers"]
weight = 700
+++
Narrow contract lvalue reference observer of the stored error. `NoValuePolicy::narrow_error_check()` is first invoked, then the reference to the error is returned. As a valid default constructed error is always present, no undefined behaviour occurs unless `NoValuePolicy::narrow_error_check()` does that.
Note that if `error_type` is `void`, only a `const` overload returning `void` is present.
*Requires*: Always available.
*Complexity*: Depends on `NoValuePolicy::narrow_error_check()`.
*Guarantees*: An exception is never thrown.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/copy_constructor.md | +++
title = "`basic_result(const basic_result &)`"
description = "Copy constructor. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "implicit-constructors", "copy-constructors"]
weight = 120
+++
Copy constructor.
*Requires*: that `value_type` and `error_type` both implement a copy constructor.
*Complexity*: Same as for `value_type`'s and `error_type`'s copy constructors. Constexpr, triviality and noexcept of underlying operations is propagated.
*Guarantees*: If an exception is thrown during the operation, the object is left in a partially completed state, as per the normal rules for the same operation on a `struct`.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/has_lost_consistency.md | +++
title = "`bool has_lost_consistency() const noexcept`"
description = "Returns true if a preceding swap involving this object failed to preserve the strong guarantee. Constexpr, never throws."
categories = ["observers"]
weight = 596
+++
Returns true if a preceding swap involving this object failed to preserve the strong guarantee. Constexpr where possible.
*Requires*: Always available.
*Complexity*: Constant time.
*Guarantees*: Never throws an exception.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/has_exception.md | +++
title = "`bool has_exception() const noexcept`"
description = "Always returns false for `basic_result`. Constexpr, never throws."
categories = ["observers"]
weight = 593
+++
Always returns false for `basic_result`. Constexpr where possible.
*Requires*: Always available.
*Complexity*: Constant time.
*Guarantees*: Never throws an exception.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/implicit_error_converting_constructor.md | +++
title = "`basic_result(S &&)`"
description = "Implicit `error_type` constructor. Available if `predicate::enable_error_converting_constructor<S>` is true. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "implicit-constructors", "converting-constructors"]
weight = 190
+++
Implicit `error_type` constructor. Calls {{% api "void on_result_construction(T *, U &&) noexcept" %}} with `this` and `S`.
*Requires*: `predicate::enable_error_converting_constructor<S>` is true.
*Complexity*: Same as for `error_type`'s copy or move constructor. Constexpr, triviality and noexcept of underlying operations is propagated. |
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/implicit_failure_copy_constructor.md | +++
title = "`basic_result(const failure_type<T> &)`"
description = "Implicit error-from-failure-type-sugar copy constructor. Available if `predicate::enable_compatible_conversion<void, T, void>` is true, or `T` is `void`. Constexpr, triviality and noexcept propagating."
categories = ["constructors", "implicit-constructors", "tagged-constructors"]
weight = 520
+++
Implicit error-from-failure-type-sugar copy constructor used to disambiguate the construction of the error type.
Note that if `T = void`, `error_type` will be default constructed. Calls {{% api "void on_result_copy_construction(T *, U &&) noexcept" %}} with `this` and `const failure_type<T> &`.
*Requires*: `predicate::enable_compatible_conversion<void, T, void>` is true, or `T` is `void`.
*Complexity*: Same as for the `error_type` constructor which accepts `T`, or the `error_type` default constructor if `T` is `void`. Constexpr, triviality and noexcept of underlying operations is propagated. |
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/basic_result/inequality_success_type.md | +++
title = "`bool operator==(const success_type<A> &) const`"
description = "Returns true if this result compares equal to the success type sugar. Constexpr and noexcept propagating."
categories = ["comparisons"]
weight = 810
+++
Returns true if this result is successful and its value compares equal to the value in the success type sugar. Comparison is done using `operator==` on `value_type` and `A`. If `A` is `void`, this call aliases {{% api "bool has_value() const noexcept" %}}.
*Requires*: `operator==` must be a valid expression between `value_type` and `A`, or `A` is `void`. If `value_type` is `void`, then so must be `A`.
*Complexity*: Whatever the underlying `operator==` has. Constexpr and noexcept of underlying operations is propagated.
*Guarantees*: None.
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/awaitables/generator.md | +++
title = "`generator<T, Executor = void>`"
description = "A lazily evaluated coroutine generator with Outcome customisation."
+++
This is a classic coroutine generator whereby the coroutine is resumed to calculate
the next value, and is suspended upon yielding that value. If the value being
yielded is an Outcome type, special semantics are used if the coroutine throws
an exception (see below).
The `Executor` template parameter is purely for compatibility with third party software
such as [ASIO](https://think-async.com/Asio/), and this awaitable can be directly used
by ASIO.
Example of use:
```c++
generator<int> func(int x)
{
while(x >= 0)
{
co_yield x--;
}
}
...
// Creates the coroutine, immediately suspending it.
auto f = func(5);
// If the coroutine has another value to yield ...
while(f)
{
// Get the next value from the coroutine
int r = f();
...
}
```
`generator<T>` has special semantics if `T` is a type capable of constructing from
an `exception_ptr` or `error_code` -- any exceptions thrown during the function's body
are sent via `T`, preferably via the error code route if {{% api "error_from_exception(" %}}`)`
successfully matches the exception throw. This means that a
{{% api "basic_result<T, E, NoValuePolicy>" %}} or {{% api "basic_outcome<T, EC, EP, NoValuePolicy>" %}} where one of its types is
is compatible will have its `.error()` or `.exception()` set.
Note that `generator<T>` does not otherwise transport exception throws, and rethrows
any exceptions thrown within the coroutine body through the coroutine machinery.
This does not produce reliable consequences in current C++ compilers. You should
therefore wrap the coroutine body in a `try...catch` if `T` is not able to transport
exceptions on its own.
*Requires*: C++ coroutines to be available in your compiler.
*Namespace*: `OUTCOME_V2_NAMESPACE::awaitables`
*Header*: `<outcome/coroutine_support.hpp>`
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/awaitables/eager.md | +++
title = "`eager<T, Executor = void>/atomic_eager<T, Executor = void>`"
description = "An eagerly evaluated coroutine awaitable with Outcome customisation."
+++
This is very similar to {{% api "lazy<T, Executor = void>" %}}, except that execution of the `eager<T>`
returning function begins immediately, and if the function never suspends during the
course of its execution, no suspend-resume cycle occurs. Functions which return `eager<T>`
are therefore suitable for tasks which *may* require suspension, but will often complete
immediately.
`atomic_eager<T>` is like `eager<T>`, except that the setting of the coroutine result
performs an atomic release, whilst the checking of whether the coroutine has finished
is an atomic acquire.
The `Executor` template parameter is purely for compatibility with third party software
such as [ASIO](https://think-async.com/Asio/), and this awaitable can be directly used
by ASIO.
Example of use (must be called from within a coroutinised function):
```c++
eager<int> func(int x)
{
co_return x + 1;
}
...
// Executes like a non-coroutine function i.e. r is immediately set to 6.
int r = co_await func(5);
```
`eager<T>` has special semantics if `T` is a type capable of constructing from
an `exception_ptr` or `error_code` -- any exceptions thrown during the function's body
are sent via `T`, preferably via the error code route if {{% api "error_from_exception(" %}}`)`
successfully matches the exception throw. This means that a
{{% api "basic_result<T, E, NoValuePolicy>" %}} or {{% api "basic_outcome<T, EC, EP, NoValuePolicy>" %}} where one of its types is
is compatible will have its `.error()` or `.exception()` set.
Note that `eager<T>` does not otherwise transport exception throws, and rethrows
any exceptions thrown within the coroutine body through the coroutine machinery.
This does not produce reliable consequences in current C++ compilers. You should
therefore wrap the coroutine body in a `try...catch` if `T` is not able to transport
exceptions on its own.
*Requires*: C++ coroutines to be available in your compiler.
*Namespace*: `OUTCOME_V2_NAMESPACE::awaitables`
*Header*: `<outcome/coroutine_support.hpp>`
|
0 | repos/outcome/doc/src/content/reference/types | repos/outcome/doc/src/content/reference/types/awaitables/lazy.md | +++
title = "`lazy<T, Executor = void>/atomic_lazy<T, Executor = void>`"
description = "A lazily evaluated coroutine awaitable with Outcome customisation."
+++
This is very similar to {{% api "eager<T, Executor = void>" %}}, except that execution of the
`lazy<T>` returning function suspends immediately. Functions which return `lazy<T>`
are therefore suitable for tasks which you need to instantiate right now, but whose
execution will occur elsewhere e.g. in a separate kernel thread. Because of the very
common use case of using worker threads to execute the body of lazily executed
coroutines, most people will want to use `atomic_lazy<T>` instead of `lazy<T>`.
`atomic_lazy<T>` is like `lazy<T>`, except that the setting of the coroutine result
performs an atomic release, whilst the checking of whether the coroutine has finished
is an atomic acquire.
`lazy<T>` has similar semantics to `std::lazy<T>`, which is being standardised. See
https://wg21.link/P1056 *Add lazy coroutine (coroutine task) type*.
The `Executor` template parameter is purely for compatibility with third party software
such as [ASIO](https://think-async.com/Asio/), and this awaitable can be directly used
by ASIO.
Example of use (must be called from within a coroutinised function):
```c++
lazy<int> func(int x)
{
co_return x + 1;
}
...
// Always suspends perhaps causing other coroutines to execute, then resumes.
int r = co_await func(5);
```
`lazy<T>` has special semantics if `T` is a type capable of constructing from
an `exception_ptr` or `error_code` -- any exceptions thrown during the function's body
are sent via `T`, preferably via the error code route if {{% api "error_from_exception(" %}}`)`
successfully matches the exception throw. This means that a
{{% api "basic_result<T, E, NoValuePolicy>" %}} or {{% api "basic_outcome<T, EC, EP, NoValuePolicy>" %}} where one of its types is
is compatible will have its `.error()` or `.exception()` set.
Note that `lazy<T>` does not otherwise transport exception throws, and rethrows
any exceptions thrown within the coroutine body through the coroutine machinery.
This does not produce reliable consequences in current C++ compilers. You should
therefore wrap the coroutine body in a `try...catch` if `T` is not able to transport
exceptions on its own.
*Requires*: C++ coroutines to be available in your compiler.
*Namespace*: `OUTCOME_V2_NAMESPACE::awaitables`
*Header*: `<outcome/coroutine_support.hpp>`
|
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/traits/is_exception_ptr_available.md | +++
title = "`is_exception_ptr_available<T>`"
description = "True if an exception ptr can be constructed from a `T`."
+++
`::value` is true if an exception ptr can be constructed from a `T` e.g. if there exists an ADL discovered free function `make_exception_ptr(T)`.
`::type` is the type that would result if `::value` is true, else `void`.
*Overridable*: By template specialisation into the `trait` namespace.
*Default*: True if `T` is an exception ptr, else to metaprogramming which performs the ADL discovery of `make_exception_ptr(T)`. Note that the STL defines an ADL discovered free function {{% api "std::make_exception_ptr(T)" %}}. Thus this trait will pick up that free function.
*Namespace*: `OUTCOME_V2_NAMESPACE::trait`
*Header*: `<outcome/trait.hpp>`
*Variable alias*: `is_exception_ptr_available_v<T>`
|
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/traits/is_error_type.md | +++
title = "`is_error_type<E>`"
description = "A customisable integral constant type true for `E` types which are to receive error throwing no-value policies."
+++
A customisable integral constant type true for `E` types which are to receive
error throwing no-value policies. Special weakened implicit construction enable
is available for integral `T` types when combined with `E` types in this
whitelist -- this permits `boost_result<int, boost::system::errc::errc_t` to
retain its implicit constructors, despite the fact that `errc_t` as a C enum
has an implicit conversion to `int`.
*Overridable*: By template specialisation into the `trait` namespace.
*Default*: False. Specialisations to true exist for:
- `<outcome/boost_result.hpp>`
- `boost::system::error_code`
- `boost::system::errc::errc_t`
- `boost::exception_ptr`
- `<outcome/std_result.hpp>`
- `std::error_code`
- `std::errc`
- `std::exception_ptr`
*Namespace*: `OUTCOME_V2_NAMESPACE::trait`
*Header*: `<outcome/trait.hpp>` |
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/traits/_index.md | +++
title = "Traits"
weight = 30
+++
{{% children description="true" depth="2" %}}
|
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/traits/type_can_be_used_in_basic_result.md | +++
title = "`type_can_be_used_in_basic_result<R>`"
description = "A constexpr boolean true for types permissible in `basic_result<T, E, NoValuePolicy>`."
+++
A constexpr boolean true for types permissible in `basic_result<T, E, NoValuePolicy>`.
*Overridable*: Not overridable.
*Definition*: True for a type which:
- Is not a reference.
- Is not an {{% api "in_place_type_t<T>" %}}.
- Is not a {{% api "success_type<T>" %}}.
- Is not a {{% api "failure_type<EC, EP = void>" %}}.
- Is not an array.
- Is either `void`, or else is an `Object` and is `Destructible`.
*Namespace*: `OUTCOME_V2_NAMESPACE::trait`
*Header*: `<outcome/trait.hpp>` |
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/traits/is_error_code_available.md | +++
title = "`is_error_code_available<T>`"
description = "True if an error code can be constructed from a `T`."
+++
`::value` is true if an error code can be constructed from a `T` e.g. if there exists an ADL discovered free function `make_error_code(T)`.
`::type` is the type that would result if `::value` is true, else `void`.
*Overridable*: By template specialisation into the `trait` namespace.
*Default*: True if `T` is an error code, else to metaprogramming which performs the ADL discovery of `make_error_code(T)`. Note that the STL defines multiple overloads of an ADL discovered free function {{% api "std::make_error_code(T)" %}} for its error enumerations, as does Boost.System for the Boost error enumerations. Thus this trait will pick up those free functions for those error types.
*Namespace*: `OUTCOME_V2_NAMESPACE::trait`
*Header*: `<outcome/trait.hpp>`
*Variable alias*: `is_error_code_available_v<T>`
|
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/traits/is_move_bitcopying.md | +++
title = "`is_move_bitcopying<T>`"
description = "(>= Outcome v2.2.0) A customisable integral constant type true for `T` types which are move bitcopying safe."
+++
A customisable integral constant type true for `T` types which are move bitcopying
safe. As per [P1029 move bitcopying](https://wg21.link/P1029), these are types for
which:
1. There is an inline, constexpr-available, default constructor.
2. The move constructor has side effects equivalent to `memcpy` of source to destination,
followed by a `memcpy` of a default constructed instance to source.
3. That the destruction of a default constructed instance has no visible
side effects.
This implies that if you move from a bit copying type, you need not call its
destructor, even if that is a virtual destructor.
If you opt your types into this trait, Outcome will track moved-from state and
not call the destructor for your type on moved-from instances. Obviously enough
this is, in current C++ standards, undefined behaviour. However it very
significantly improves the quality of codegen during inlining.
*Overridable*: By template specialisation into the `trait` namespace.
*Default*: False. Default specialisations exist for:
- `<outcome/experimental/status_result.hpp>`
- True for `SYSTEM_ERROR2_NAMESPACE::status_code<DomainType>` if trait
`SYSTEM_ERROR2_NAMESPACE::traits::is_move_bitcopying<SYSTEM_ERROR2_NAMESPACE::status_code<DomainType>>::value`
is true.
- True for `SYSTEM_ERROR2_NAMESPACE::errored_status_code<DomainType>` if trait
`SYSTEM_ERROR2_NAMESPACE::traits::is_move_bitcopying<SYSTEM_ERROR2_NAMESPACE::errored_status_code<DomainType>>::value`
is true.
*Namespace*: `OUTCOME_V2_NAMESPACE::trait`
*Header*: `<outcome/trait.hpp>` |
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/traits/is_basic_result.md | +++
title = "`is_basic_result<T>`"
description = "An integral constant type true for `basic_result<T, E, NoValuePolicy>` types."
+++
An integral constant type true for {{% api "basic_result<T, E, NoValuePolicy>" %}} types. This does not match anything not exactly a `basic_result`. If you want to match types like `basic_result` but not equal to it, consider {{% api "basic_result<T>" %}} or {{% api "value_or_error<T>" %}}.
*Overridable*: Not overridable.
*Namespace*: `OUTCOME_V2_NAMESPACE`
*Header*: `<outcome/basic_result.hpp>`
*Variable alias*: `is_basic_result_v<T>`
|
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/traits/is_success_type.md | +++
title = "`is_success_type<T>`"
description = "An integral constant boolean variable true for `success_type<T>` types."
+++
An integral constant boolean variable true for {{% api "success_type<T>" %}} types.
*Overridable*: Not overridable.
*Namespace*: `OUTCOME_V2_NAMESPACE`
*Header*: `<outcome/success_failure.hpp>`
|
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/traits/is_error_type_enum.md | +++
title = "`is_error_type_enum<E, Enum>`"
description = "A customisable integral constant type true for `E` types constructible from `Enum` types which are to receive error throwing no-value policies."
+++
A customisable integral constant type true for `E` types constructible from `Enum` types which are to receive error throwing no-value policies
*Overridable*: By template specialisation into the `trait` namespace.
*Default*: False. Specialisations exist for:
- `<outcome/boost_result.hpp>`
- `boost::system::error_code` to `boost::system::is_error_condition_enum<Enum>::value`.
- `<outcome/std_result.hpp>`
- `std::error_code` to `std::is_error_condition_enum<Enum>::value`.
*Namespace*: `OUTCOME_V2_NAMESPACE::trait`
*Header*: `<outcome/trait.hpp>` |
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/traits/is_failure_type.md | +++
title = "`is_failure_type<T>`"
description = "An integral constant boolean variable true for `failure_type<EC, E = void>` types."
+++
An integral constant boolean variable true for {{% api "failure_type<EC, EP = void>" %}} types.
*Overridable*: Not overridable.
*Namespace*: `OUTCOME_V2_NAMESPACE`
*Header*: `<outcome/success_failure.hpp>`
|
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/traits/is_basic_outcome.md | +++
title = "`is_basic_outcome<T>`"
description = "An integral constant type true for `basic_outcome<T, EC, EP, NoValuePolicy>` types."
+++
An integral constant type true for {{% api "basic_outcome<T, EC, EP, NoValuePolicy>" %}} types. This does not match anything not exactly a `basic_outcome`. If you want to match types like `basic_outcome` but not equal to it, consider {{% api "basic_outcome<T>" %}}..
*Overridable*: Not overridable.
*Namespace*: `OUTCOME_V2_NAMESPACE`
*Header*: `<outcome/basic_outcome.hpp>`
*Variable alias*: `is_basic_outcome_v<T>`
|
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/is_nothrow_swappable.md | +++
title = "`OUTCOME_USE_STD_IS_NOTHROW_SWAPPABLE`"
description = "How to implement `is_nothrow_swappable<T>`."
+++
Whether to implement `is_nothrow_swappable<T>` as `std::is_nothrow_swappable<T>`,
or else use a local emulation.
*Overridable*: Define before inclusion.
*Default*: If the current compiler implements C++ 17 or later, if unset
this macro is defaulted to `1`, otherwise it is defaulted to `0`.
*Header*: `<outcome/config.hpp>` |
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/co_tryv2_failure_likely.md | +++
title = "`OUTCOME_CO_TRYV2_FAILURE_LIKELY(spec, expr)`"
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."
+++
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:
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_has_value(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_return_as(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_extract_value(X)" %}}
Default overloads for these customisation points are provided. See [the recipe for supporting foreign input to `OUTCOME_TRY`]({{% relref "/recipes/foreign-try" %}}).
Hints are given to the compiler that the expression will be unsuccessful. If you expect success, you should use {{% api "OUTCOME_TRYV(expr)" %}} instead.
*Overridable*: Not overridable.
*Definition*: Firstly the expression's temporary is bound to a uniquely named, stack allocated, `spec`. 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.
*Header*: `<outcome/try.hpp>`
|
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/version.md | +++
title = "Version macros"
+++
*Overridable*: None of the following macros are overridable.
*Header*: `<outcome/config.hpp>`
- <a name="version-major"></a>`OUTCOME_VERSION_MAJOR <number>`
Major version for cmake and DLL version stamping.
- <a name="version-minor"></a>`OUTCOME_VERSION_MINOR <number>`
Minor version for cmake and DLL version stamping.
- <a name="version-patch"></a>`OUTCOME_VERSION_PATCH <number>`
Patch version for cmake and DLL version stamping.
- <a name="version-revision"></a>`OUTCOME_VERSION_REVISION <number>`
Revision version for cmake and DLL version stamping.
- <a name="unstable-version"></a>`OUTCOME_UNSTABLE_VERSION <number>`
Defined between stable releases of Outcome. It means the inline namespace will be permuted per-commit to ensure ABI uniqueness such that multiple versions of Outcome in a single process space cannot collide.
- <a name="v2"></a>`OUTCOME_V2 <tokens>`
The namespace configuration of this Outcome v2. Consists of a sequence of bracketed tokens later fused by the preprocessor into namespace and C++ module names.
- <a name="v2-namespace"></a>`OUTCOME_V2_NAMESPACE <identifier>`
The Outcome namespace, which may be permuted per SHA commit. This is not fully qualified.
- <a name="v2-namespace-begin"></a>`OUTCOME_V2_NAMESPACE_BEGIN <keywords and identifiers>`
Expands into the appropriate namespace markup to enter the Outcome v2 namespace.
- <a name="v2-namespace-export-begin"></a>`OUTCOME_V2_NAMESPACE_EXPORT_BEGIN <keywords and identifiers>`
Expands into the appropriate namespace markup to enter the C++ module exported Outcome v2 namespace.
- <a name="v2-namespace-end"></a>`OUTCOME_V2_NAMESPACE_END <keywords and identifiers>`
Expands into the appropriate namespace markup to exit the Outcome v2 namespace.
|
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/co_tryv_failure_likely.md | +++
title = "`OUTCOME_CO_TRYV_FAILURE_LIKELY(expr)/OUTCOME_CO_TRY_FAILURE_LIKELY(expr)`"
description = "Evaluate from within a coroutine 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."
+++
Evaluate from within a coroutine 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:
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_has_value(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_return_as(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_extract_value(X)" %}}
Default overloads for these customisation points are provided. See [the recipe for supporting foreign input to `OUTCOME_TRY`]({{% relref "/recipes/foreign-try" %}}).
The difference between the `OUTCOME_CO_TRYV(expr)` and `OUTCOME_CO_TRY(expr)` editions is that the latter will set a variable if two or more macro arguments are present (see {{% api "OUTCOME_CO_TRY(var, expr)" %}}). The former requires the `T` to be `void`.
Hints are given to the compiler that the expression will be unsuccessful. If you expect success, you should use {{% api "OUTCOME_CO_TRYV(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.]({{% relref "/tutorial/essential/result/try_ref" %}})
*Overridable*: Not overridable.
*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.
*Header*: `<outcome/try.hpp>`
|
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/enable_legacy_support_for.md | +++
title = "`OUTCOME_ENABLE_LEGACY_SUPPORT_FOR`"
description = "Enables backwards features and naming compatibility for earlier versions of Outcome."
+++
As Outcome has evolved, some features and especially naming were retired in newer versions. Define this macro to enable backwards compatibility aliasing from old features and naming to new features and naming.
*Overridable*: Define before inclusion.
*Default*: The current version of Outcome, expressed in hundreds e.g. Outcome v2.10 is `210`.
*Header*: `<outcome/config.hpp>` |
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/in_place_type.md | +++
title = "`OUTCOME_USE_STD_IN_PLACE_TYPE`"
description = "How to implement `in_place_type_t<T>` and `in_place_type<T>`."
+++
How to implement {{% api "in_place_type_t<T>" %}} and `in_place_type<T>`.
If set to `1`, the `<utility>` header is included, and `std::in_place_type_t<T>`
is aliased into `OUTCOME_V2_NAMESPACE::in_place_type_t<T>` along with
`std::in_place_type<T>`.
If set to `0`, a local emulation is used.
*Overridable*: Define before inclusion.
*Default*: If the current compiler implements C++ 17 or later, if unset
this macro is defaulted to `1`, otherwise it is defaulted to `0`.
*Header*: `<outcome/config.hpp>` |
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/co_try_failure_likely.md | +++
title = "`OUTCOME_CO_TRY_FAILURE_LIKELY(var, expr)`"
description = "Evaluate within a coroutine an expression which results in an understood type, assigning `T` to a decl called `var` if successful, immediately returning `try_operation_return_as(X)` from the calling function if unsuccessful."
+++
Evaluate within a coroutine an expression which results in a type matching the following customisation points, assigning `T` to a decl called `var` if successful, immediately returning {{% api "try_operation_return_as(X)" %}} from the calling function if unsuccessful:
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_has_value(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_return_as(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_extract_value(X)" %}}
Default overloads for these customisation points are provided. See [the recipe for supporting foreign input to `OUTCOME_TRY`]({{% relref "/recipes/foreign-try" %}}).
Hints are given to the compiler that the expression will be unsuccessful. If you expect success, you should use {{% api "OUTCOME_CO_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.]({{% relref "/tutorial/essential/result/try_ref" %}})
*Overridable*: Not overridable.
*Definition*: See {{% api "OUTCOME_CO_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*: `<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.
|
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/_index.md | +++
title = "Macros"
weight = 10
+++
{{% children description="true" depth="2" %}}
|
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/disable_execinfo.md | +++
title = "`OUTCOME_DISABLE_EXECINFO`"
description = "If defined, disables the use of the `<execinfo.h>` header (or the win32 emulation)."
+++
If defined, disables the use of the `<execinfo.h>` header (or the win32 emulation).
Some embedded Linux toolchains do not define `<execinfo.h>`, thus disabling C++ exceptions on those toolchains produces a failure to find this file. Avoid that problem by defining this macro to disable stack backtrace support entirely.
*Overridable*: Define before inclusion.
*Default*: Defined if `__ANDROID__` is defined, else undefined.
*Header*: `<outcome/config.hpp>` |
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/try_failure_likely.md | +++
title = "`OUTCOME_TRY_FAILURE_LIKELY(var, expr)`"
description = "Evaluate an expression which results in an understood type, assigning `T` to a decl called `var` if successful, immediately returning `try_operation_return_as(X)` from the calling function if unsuccessful."
+++
Evaluate an expression which results in a type matching the following customisation points, assigning `T` to a decl called `var` if successful, immediately returning {{% api "try_operation_return_as(X)" %}} from the calling function if unsuccessful:
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_has_value(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_return_as(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_extract_value(X)" %}}
Default overloads for these customisation points are provided. See [the recipe for supporting foreign input to `OUTCOME_TRY`]({{% relref "/recipes/foreign-try" %}}).
Hints are given to the compiler that the expression will be unsuccessful. If you expect success, you should use {{% api "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.]({{% relref "/tutorial/essential/result/try_ref" %}})
*Overridable*: Not overridable.
*Definition*: See {{% api "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*: `<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.
|
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/tryv_failure_likely.md | +++
title = "`OUTCOME_TRYV_FAILURE_LIKELY(expr)/OUTCOME_TRY_FAILURE_LIKELY(expr)`"
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."
+++
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:
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_has_value(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_return_as(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_extract_value(X)" %}}
Default overloads for these customisation points are provided. See [the recipe for supporting foreign input to `OUTCOME_TRY`]({{% relref "/recipes/foreign-try" %}}).
The difference between the `OUTCOME_TRYV(expr)` and `OUTCOME_TRY(expr)` editions is that the latter will set a variable if two or more macro arguments are present (see {{% api "OUTCOME_TRY(var, expr)" %}}). The former requires the `T` to be `void`.
Hints are given to the compiler that the expression will be unsuccessful. If you expect success, you should use {{% api "OUTCOME_TRYV(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.]({{% relref "/tutorial/essential/result/try_ref" %}})
*Overridable*: Not overridable.
*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.
*Header*: `<outcome/try.hpp>`
|
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/nodiscard.md | +++
title = "`OUTCOME_NODISCARD`"
description = "How to tell the compiler than the return value of a function should not be discarded without examining it."
+++
Compiler-specific markup used to tell the compiler than the return value of a function should not be discarded without examining it.
*Overridable*: Define before inclusion.
*Default*: To `[[nodiscard]]` if on C++ 17 or higher, `__attribute__((warn_unused_result))` if on clang, SAL `_Must_inspect_result_` if on MSVC, otherwise nothing.
*Header*: `<outcome/config.hpp>` |
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/co_tryv2.md | +++
title = "`OUTCOME_CO_TRYV2(spec, expr)`"
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."
+++
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:
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_has_value(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_return_as(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_extract_value(X)" %}}
Default overloads for these customisation points are provided. See [the recipe for supporting foreign input to `OUTCOME_TRY`]({{% relref "/recipes/foreign-try" %}}).
Hints are given to the compiler that the expression will be successful. If you expect failure, you should use {{% api "OUTCOME_TRYV2_FAILURE_LIKELY(spec, expr)" %}} instead.
*Overridable*: Not overridable.
*Definition*: Firstly the expression's temporary is bound to a uniquely named, stack allocated, `spec`. 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.
*Header*: `<outcome/try.hpp>`
|
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/requires.md | +++
title = "`OUTCOME_REQUIRES(...)`"
description = "A C++ 20 `requires(...)`, if available."
+++
A C++ 20 `requires(...)`, if available.
*Overridable*: Define before inclusion.
*Default*: To `requires(...)` if on C++ 20 or later, else to nothing.
*Header*: `<outcome/config.hpp>` |
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/co_tryx_failure_likely.md | +++
title = "`OUTCOME_CO_TRYX_FAILURE_LIKELY(expr)`"
description = "Evaluate from within a coroutine an expression which results in an understood type, emitting the `T` if successful, immediately returning `try_operation_return_as(X)` from the calling function if unsuccessful."
+++
Evaluate within a coroutine an expression which results in a type matching the following customisation points, emitting the `T` if successful, immediately returning {{% api "try_operation_return_as(X)" %}} from the calling function if unsuccessful:
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_has_value(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_return_as(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_extract_value(X)" %}}
Default overloads for these customisation points are provided. See [the recipe for supporting foreign input to `OUTCOME_TRY`]({{% relref "/recipes/foreign-try" %}}).
Hints are given to the compiler that the expression will be unsuccessful. If you expect success, you should use {{% api "OUTCOME_CO_TRYX(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.]({{% relref "/tutorial/essential/result/try_ref" %}})
*Availability*: GCC and clang only. Use `#ifdef OUTCOME_CO_TRYX` to determine if available.
*Overridable*: Not overridable.
*Definition*: See {{% api "OUTCOME_CO_TRYV(expr)" %}} for most of the mechanics.
This macro makes use of a proprietary extension in GCC and clang to emit the `T` from a successful expression. You can thus use `OUTCOME_CO_TRYX(expr)` directly in expressions e.g. `auto x = y + OUTCOME_CO_TRYX(foo(z));`.
Be aware there are compiler quirks in preserving the rvalue/lvalue/etc-ness of emitted `T`'s, specifically copy or move constructors may be called unexpectedly and/or copy elision not work as expected. If these prove to be problematic, use {{% api "OUTCOME_CO_TRY(var, expr)" %}} instead.
*Header*: `<outcome/try.hpp>`
|
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/tryv2.md | +++
title = "`OUTCOME_TRYV2(spec, expr)`"
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."
+++
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:
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_has_value(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_return_as(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_extract_value(X)" %}}
Default overloads for these customisation points are provided. See [the recipe for supporting foreign input to `OUTCOME_TRY`]({{% relref "/recipes/foreign-try" %}}).
Hints are given to the compiler that the expression will be successful. If you expect failure, you should use {{% api "OUTCOME_TRYV2_FAILURE_LIKELY(spec, expr)" %}} instead.
*Overridable*: Not overridable.
*Definition*: Firstly the expression's temporary is bound to a uniquely named, stack allocated, `spec`. 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.
*Header*: `<outcome/try.hpp>`
|
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/co_try.md | +++
title = "`OUTCOME_CO_TRY(var, expr)`"
description = "Evaluate within a coroutine an expression which results in an understood type, assigning `T` to a decl called `var` if successful, immediately returning `try_operation_return_as(X)` from the calling function if unsuccessful."
+++
Evaluate within a coroutine an expression which results in a type matching the following customisation points, assigning `T` to a decl called `var` if successful, immediately returning {{% api "try_operation_return_as(X)" %}} from the calling function if unsuccessful:
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_has_value(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_return_as(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_extract_value(X)" %}}
Default overloads for these customisation points are provided. See [the recipe for supporting foreign input to `OUTCOME_TRY`]({{% relref "/recipes/foreign-try" %}}).
Hints are given to the compiler that the expression will be successful. If you expect failure, you should use {{% api "OUTCOME_CO_TRY_FAILURE_LIKELY(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.]({{% relref "/tutorial/essential/result/try_ref" %}})
*Overridable*: Not overridable.
*Definition*: See {{% api "OUTCOME_CO_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*: `<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. |
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/co_tryx.md | +++
title = "`OUTCOME_CO_TRYX(expr)`"
description = "Evaluate from within a coroutine an expression which results in an understood type, emitting the `T` if successful, immediately returning `try_operation_return_as(X)` from the calling function if unsuccessful."
+++
Evaluate within a coroutine an expression which results in a type matching the following customisation points, emitting the `T` if successful, immediately returning {{% api "try_operation_return_as(X)" %}} from the calling function if unsuccessful:
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_has_value(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_return_as(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_extract_value(X)" %}}
Default overloads for these customisation points are provided. See [the recipe for supporting foreign input to `OUTCOME_TRY`]({{% relref "/recipes/foreign-try" %}}).
Hints are given to the compiler that the expression will be successful. If you expect failure, you should use {{% api "OUTCOME_CO_TRYX_FAILURE_LIKELY(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.]({{% relref "/tutorial/essential/result/try_ref" %}})
*Availability*: GCC and clang only. Use `#ifdef OUTCOME_CO_TRYX` to determine if available.
*Overridable*: Not overridable.
*Definition*: See {{% api "OUTCOME_CO_TRYV(expr)" %}} for most of the mechanics.
This macro makes use of a proprietary extension in GCC and clang to emit the `T` from a successful expression. You can thus use `OUTCOME_CO_TRYX(expr)` directly in expressions e.g. `auto x = y + OUTCOME_CO_TRYX(foo(z));`.
Be aware there are compiler quirks in preserving the rvalue/lvalue/etc-ness of emitted `T`'s, specifically copy or move constructors may be called unexpectedly and/or copy elision not work as expected. If these prove to be problematic, use {{% api "OUTCOME_CO_TRY(var, expr)" %}} instead.
*Header*: `<outcome/try.hpp>`
|
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/symbol_visible.md | +++
title = "`OUTCOME_SYMBOL_VISIBLE`"
description = "How to mark throwable types as always having default ELF symbol visibility."
+++
Compiler-specific markup used to mark throwable types as always having default ELF symbol visibility, without which it will be impossible to catch throws of such types across shared library boundaries on ELF only.
*Overridable*: Define before inclusion.
*Default*:<dl>
<dt>Standalone Outcome:
<dd>To `__attribute__((visibility("default"))` on GCC and clang when targeting ELF, otherwise nothing.
<dt>Boost.Outcome:
<dd>To `BOOST_SYMBOL_VISIBLE`.
</dl>
*Header*: `<outcome/config.hpp>` |
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/thread_local.md | +++
title = "`OUTCOME_THREAD_LOCAL`"
description = "How to mark variables as having thread local storage duration."
+++
Compiler-specific markup used to mark variables as having thread local storage duration.
{{% notice note %}}
This isn't used inside Outcome, but is used by its unit test suite.
{{% /notice %}}
*Overridable*: Define before inclusion.
*Default*: To `thread_local` if the compiler implements C++ 11 `thread_local`, else `__thread` for the one supported compiler (older Mac OS XCode) which does not.
*Header*: `<outcome/config.hpp>` |
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/tryv.md | +++
title = "`OUTCOME_TRYV(expr)/OUTCOME_TRY(expr)`"
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."
+++
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:
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_has_value(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_return_as(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_extract_value(X)" %}}
Default overloads for these customisation points are provided. See [the recipe for supporting foreign input to `OUTCOME_TRY`]({{% relref "/recipes/foreign-try" %}}).
The difference between the `OUTCOME_TRYV(expr)` and `OUTCOME_TRY(expr)` editions is that the latter will set a variable if two or more macro arguments are present (see {{% api "OUTCOME_TRY(var, expr)" %}}). The former requires the `T` to be `void`.
Hints are given to the compiler that the expression will be successful. If you expect failure, you should use {{% api "OUTCOME_TRYV_FAILURE_LIKELY(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.]({{% relref "/tutorial/essential/result/try_ref" %}})
*Overridable*: Not overridable.
*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.
*Header*: `<outcome/try.hpp>`
|
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/throw_exception.md | +++
title = "`OUTCOME_THROW_EXCEPTION(expr)`"
description = "How to throw a C++ exception, or equivalent thereof."
+++
Throws a C++ exception, or equivalent thereof.
*Overridable*: Define before inclusion.
*Default*:<dl>
<dt>Standalone Outcome (C++ exceptions enabled):
<dd>To `throw expr`
<dt>Standalone Outcome (C++ exceptions disabled):
<dd>To `OUTCOME_V2_NAMESPACE::detail::do_fatal_exit(#expr)` which is a function which prints a useful error message including a stack backtrace (where available) to `stderr` before calling `abort()`.
<dt>Boost.Outcome:
<dd>To `BOOST_THROW_EXCEPTION(expr)`.
</dl>
*Header*: `<outcome/config.hpp>` |
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/tryx_failure_likely.md | +++
title = "`OUTCOME_TRYX_FAILURE_LIKELY(expr)`"
description = "Evaluate an expression which results in an understood type, emitting the `T` if successful, immediately returning `try_operation_return_as(X)` from the calling function if unsuccessful."
+++
Evaluate an expression which results in a type matching the following customisation points, emitting the `T` if successful, immediately returning {{% api "try_operation_return_as(X)" %}} from the calling function if unsuccessful:
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_has_value(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_return_as(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_extract_value(X)" %}}
Default overloads for these customisation points are provided. See [the recipe for supporting foreign input to `OUTCOME_TRY`]({{% relref "/recipes/foreign-try" %}}).
Hints are given to the compiler that the expression will be unsuccessful. If you expect success, you should use {{% api "OUTCOME_TRYX(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.]({{% relref "/tutorial/essential/result/try_ref" %}})
*Availability*: GCC and clang only. Use `#ifdef OUTCOME_TRYX` to determine if available.
*Overridable*: Not overridable.
*Definition*: See {{% api "OUTCOME_TRYV(expr)" %}} for most of the mechanics.
This macro makes use of a proprietary extension in GCC and clang to emit the `T` from a successful expression. You can thus use `OUTCOME_TRYX(expr)` directly in expressions e.g. `auto x = y + OUTCOME_TRYX(foo(z));`.
Be aware there are compiler quirks in preserving the rvalue/lvalue/etc-ness of emitted `T`'s, specifically copy or move constructors may be called unexpectedly and/or copy elision not work as expected. If these prove to be problematic, use {{% api "OUTCOME_TRY(var, expr)" %}} instead.
*Header*: `<outcome/try.hpp>`
|
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/co_tryv.md | +++
title = "`OUTCOME_CO_TRYV(expr)/OUTCOME_CO_TRY(expr)`"
description = "Evaluate from within a coroutine 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."
+++
Evaluate from within a coroutine 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:
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_has_value(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_return_as(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_extract_value(X)" %}}
Default overloads for these customisation points are provided. See [the recipe for supporting foreign input to `OUTCOME_TRY`]({{% relref "/recipes/foreign-try" %}}).
The difference between the `OUTCOME_CO_TRYV(expr)` and `OUTCOME_CO_TRY(expr)` editions is that the latter will set a variable if two or more macro arguments are present (see {{% api "OUTCOME_CO_TRY(var, expr)" %}}). The former requires the `T` to be `void`.
Hints are given to the compiler that the expression will be successful. If you expect failure, you should use {{% api "OUTCOME_CO_TRYV_FAILURE_LIKELY(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.]({{% relref "/tutorial/essential/result/try_ref" %}})
*Overridable*: Not overridable.
*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.
*Header*: `<outcome/try.hpp>`
|
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/try.md | +++
title = "`OUTCOME_TRY(var, expr)`"
description = "Evaluate an expression which results in an understood type, assigning `T` to a decl called `var` if successful, immediately returning `try_operation_return_as(X)` from the calling function if unsuccessful."
+++
Evaluate an expression which results in a type matching the following customisation points, assigning `T` to a decl called `var` if successful, immediately returning {{% api "try_operation_return_as(X)" %}} from the calling function if unsuccessful:
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_has_value(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_return_as(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_extract_value(X)" %}}
Default overloads for these customisation points are provided. See [the recipe for supporting foreign input to `OUTCOME_TRY`]({{% relref "/recipes/foreign-try" %}}).
Hints are given to the compiler that the expression will be successful. If you expect failure, you should use {{% api "OUTCOME_TRY_FAILURE_LIKELY(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.]({{% relref "/tutorial/essential/result/try_ref" %}})
*Overridable*: Not overridable.
*Definition*: See {{% api "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*: `<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_TRY()` if wish to retain the old behaviour. |
0 | repos/outcome/doc/src/content/reference | repos/outcome/doc/src/content/reference/macros/tryv2_failure_likely.md | +++
title = "`OUTCOME_TRYV2_FAILURE_LIKELY(spec, expr)`"
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."
+++
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:
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_has_value(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_return_as(X)" %}}
- `OUTCOME_V2_NAMESPACE::`{{% api "try_operation_extract_value(X)" %}}
Default overloads for these customisation points are provided. See [the recipe for supporting foreign input to `OUTCOME_TRY`]({{% relref "/recipes/foreign-try" %}}).
Hints are given to the compiler that the expression will be unsuccessful. If you expect success, you should use {{% api "OUTCOME_TRYV(expr)" %}} instead.
*Overridable*: Not overridable.
*Definition*: Firstly the expression's temporary is bound to a uniquely named, stack allocated, `spec`. 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.
*Header*: `<outcome/try.hpp>`
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.