outcome<R, S, P>

Header file outcome.hpp

namespace outcome_v2_xxx
{
    template <class T>
    using is_outcome = 'hidden';

    template <class T>static constexpr bool is_outcome_v = detail::is_outcome<std::decay_t<T>>::value;

    namespace hooks
    {
        template <class T, class U>
        constexpr void hook_outcome_construction(T*, U&&) noexcept;

        template <class T, class U>
        constexpr void hook_outcome_copy_construction(T*, U&&) noexcept;

        template <class T, class U>
        constexpr void hook_outcome_move_construction(T*, U&&) noexcept;

        template <class T, class U, class ... Args>
        constexpr void hook_outcome_in_place_construction(T*, in_place_type_t<U>, Args &&...) noexcept;

        template <class R, class S, class P, class NoValuePolicy, class U>
        constexpr void override_outcome_exception(outcome<R, S, P, NoValuePolicy>* o, U&& v) noexcept;
    }

    template <class R, class S, class P, class NoValuePolicy>
    class outcome;

    template <class T, class U, class V, class R, class S, class P, class N>
    constexpr bool operator==(result<T, U, V> const& a, outcome<R, S, P, N> const& b) noexcept('hidden');

    template <class T, class U, class V, class R, class S, class P, class N>
    constexpr bool operator!=(result<T, U, V> const& a, outcome<R, S, P, N> const& b) noexcept('hidden');

    template <class R, class S, class P, class N>
    void swap(outcome<R, S, P, N>& a, outcome<R, S, P, N>& b) noexcept('hidden');

    namespace hooks
    {
        template <class R, class S, class P, class NoValuePolicy, class U>
        constexpr void override_outcome_exception(outcome<R, S, P, NoValuePolicy>* o, U&& v) noexcept;
    }
}

Alias template outcome_v2_xxx::is_outcome

template <class T>
using is_outcome = 'hidden';

True if an outcome


Unexposed entity outcome_v2_xxx::is_outcome_v

template <class T>static constexpr bool is_outcome_v = detail::is_outcome<std::decay_t<T>>::value;

True if an outcome


Function outcome_v2_xxx::hooks::hook_outcome_construction

template <class T, class U>
constexpr void hook_outcome_construction(T*, U&&) noexcept;

The default instantiation hook implementation called when a outcome is first created by conversion from one of its possible types. Does nothing.

WARNING: The compiler is permitted to elide calls to constructors, and thus this hook may not get called when you think it should!

Parameters

  • — Some outcome<...> being constructed.

Function outcome_v2_xxx::hooks::hook_outcome_copy_construction

template <class T, class U>
constexpr void hook_outcome_copy_construction(T*, U&&) noexcept;

The default instantiation hook implementation called when a outcome is created by copying from another outcome or result. Does nothing.

WARNING: The compiler is permitted to elide calls to constructors, and thus this hook may not get called when you think it should!

Parameters

  • — Some outcome<...> being constructed.

Function outcome_v2_xxx::hooks::hook_outcome_move_construction

template <class T, class U>
constexpr void hook_outcome_move_construction(T*, U&&) noexcept;

The default instantiation hook implementation called when a outcome is created by moving from another outcome or result. Does nothing.

WARNING: The compiler is permitted to elide calls to constructors, and thus this hook may not get called when you think it should!

Parameters

  • — Some outcome<...> being constructed.

Function outcome_v2_xxx::hooks::hook_outcome_in_place_construction

template <class T, class U, class ... Args>
constexpr void hook_outcome_in_place_construction(T*, in_place_type_t<U>, Args &&...) noexcept;

The default instantiation hook implementation called when a outcome is created by in place construction. Does nothing.

WARNING: The compiler is permitted to elide calls to constructors, and thus this hook may not get called when you think it should!

Parameters

  • — Some outcome<...> being constructed.
  • — The type of in place construction occurring.

Function outcome_v2_xxx::hooks::override_outcome_exception

template <class R, class S, class P, class NoValuePolicy, class U>
constexpr void override_outcome_exception(outcome<R, S, P, NoValuePolicy>* o, U&& v) noexcept;

Used in hook implementations to override the payload/exception to something other than what was constructed.


Class outcome_v2_xxx::outcome

template <class R, class S, class P, class NoValuePolicy>
class outcome
{
public:
    //=== Member types ===//
    using value_type = R;

    using error_type = S;

    using exception_type = P;

    template <class T, class U = S, class V = P, class W = policy::default_policy<T,U,V>>
    using rebind = outcome<T, U, V, W>;

protected:
    struct predicate;

public:
    using value_type_if_enabled = std::conditional_t<std::is_same<value_type, error_type>::value || std::is_same<value_type, exception_type>::value, disable_in_place_value_type, value_type>;

    using error_type_if_enabled = std::conditional_t<std::is_same<error_type, value_type>::value || std::is_same<error_type, exception_type>::value, disable_in_place_error_type, error_type>;

    using exception_type_if_enabled = std::conditional_t<std::is_same<exception_type, value_type>::value || std::is_same<exception_type, error_type>::value, disable_in_place_exception_type, exception_type>;

protected:
    'hidden' _ptr;

public:
    template <class T>
    constexpr outcome(T&& t) noexcept('hidden');

    template <class T>
    constexpr outcome(T&& t) noexcept('hidden');

    template <class ErrorCondEnum>
    constexpr outcome(ErrorCondEnum&& t) noexcept('hidden');

    template <class T>
    constexpr outcome(T&& t) noexcept('hidden');

    template <class T>
    constexpr outcome(T&& o);

    template <class T, class U, class V, class W>
    constexpr outcome(outcome<T, U, V, W> const& o) noexcept('hidden');

    template <class T, class U, class V, class W>
    constexpr outcome(outcome<T, U, V, W>&& o) noexcept('hidden');

    template <class T, class U, class V>
    constexpr outcome(result<T, U, V> const& o) noexcept('hidden');

    template <class T, class U, class V>
    constexpr outcome(result<T, U, V>&& o) noexcept('hidden');

    template <class ... Args>
    constexpr outcome(in_place_type_t<outcome_v2_xxx::outcome::value_type_if_enabled> _, Args &&... args) noexcept('hidden');

    template <class U, class ... Args>
    constexpr outcome(in_place_type_t<outcome_v2_xxx::outcome::value_type_if_enabled> _, std::initializer_list<U> il, Args &&... args) noexcept('hidden');

    template <class ... Args>
    constexpr outcome(in_place_type_t<outcome_v2_xxx::outcome::error_type_if_enabled> _, Args &&... args) noexcept('hidden');

    template <class U, class ... Args>
    constexpr outcome(in_place_type_t<outcome_v2_xxx::outcome::error_type_if_enabled> _, std::initializer_list<U> il, Args &&... args) noexcept('hidden');

    template <class ... Args>
    constexpr outcome(in_place_type_t<outcome_v2_xxx::outcome::exception_type_if_enabled>, Args &&... args) noexcept('hidden');

    template <class U, class ... Args>
    constexpr outcome(in_place_type_t<outcome_v2_xxx::outcome::exception_type_if_enabled>, std::initializer_list<U> il, Args &&... args) noexcept('hidden');

    template <class A1, class A2, class ... Args>
    constexpr outcome(A1&& a1, A2&& a2, Args &&... args) noexcept('hidden');

    constexpr outcome(success_type<void> const& o) noexcept('hidden');

    template <class T>
    constexpr outcome(success_type<T> const& o) noexcept('hidden');

    template <class T>
    constexpr outcome(success_type<T>&& o) noexcept('hidden');

    template <class T, class U>
    constexpr outcome(failure_type<T, U> const& o) noexcept('hidden');

    template <class T, class U>
    constexpr outcome(failure_type<T, U>&& o) noexcept('hidden');

    template <class T, class U, class V, class W>
    constexpr bool operator==(outcome<T, U, V, W> const& o) const noexcept('hidden');

    template <class T, class U>
    constexpr bool operator==(failure_type<T, U> const& o) const noexcept('hidden');

    template <class T, class U, class V, class W>
    constexpr bool operator!=(outcome<T, U, V, W> const& o) const noexcept('hidden');

    template <class T, class U>
    constexpr bool operator!=(failure_type<T, U> const& o) const noexcept('hidden');

    void swap(outcome<R, S, P, NoValuePolicy>& o) noexcept('hidden');

    failure_type<outcome_v2_xxx::outcome::error_type, outcome_v2_xxx::outcome::exception_type> as_failure() const &;

    failure_type<outcome_v2_xxx::outcome::error_type, outcome_v2_xxx::outcome::exception_type> as_failure() &&;

    using exception_type = std::exception_ptr;

    exception_type failure() const noexcept;

    using exception_type = 'hidden';

    //=== assume_exception ===//
    constexpr exception_type& assume_exception() & noexcept;
    constexpr exception_type& assume_exception() const & noexcept;
    constexpr exception_type&& assume_exception() && noexcept;
    constexpr exception_type&& assume_exception() const && noexcept;

    //=== exception ===//
    constexpr exception_type& exception() &;
    constexpr exception_type& exception() const &;
    constexpr exception_type&& exception() &&;
    constexpr exception_type&& exception() const &&;

    using error_type = 'hidden';

    //=== assume_error ===//
    constexpr error_type& assume_error() & noexcept;
    constexpr error_type& assume_error() const & noexcept;
    constexpr error_type&& assume_error() && noexcept;
    constexpr error_type&& assume_error() const && noexcept;

    //=== error ===//
    constexpr error_type& error() &;
    constexpr error_type& error() const &;
    constexpr error_type&& error() &&;
    constexpr error_type&& error() const &&;

    explicit operator bool() const noexcept;

    constexpr bool has_value() const noexcept;

    constexpr bool has_error() const noexcept;

    constexpr bool has_exception() const noexcept;

    constexpr bool has_failure() const noexcept;

    template <class T, class U, class V>
    constexpr bool operator==('hidden' const& o) const noexcept('hidden');

    template <class T>
    constexpr bool operator==(success_type<T> const& o) const noexcept('hidden');

    constexpr bool operator==(success_type<void> const& o) const noexcept;

    template <class T>
    constexpr bool operator==(failure_type<T, void> const& o) const noexcept('hidden');

    template <class T, class U, class V>
    constexpr bool operator!=('hidden' const& o) const noexcept('hidden');

    template <class T>
    constexpr bool operator!=(success_type<T> const& o) const noexcept('hidden');

    constexpr bool operator!=(success_type<void> const& o) const noexcept;

    template <class T>
    constexpr bool operator!=(failure_type<T, void> const& o) const noexcept('hidden');
};

Used to return from functions one of (i) a successful value (ii) a cause of failure (ii) a different cause of failure. constexpr capable.

This is an extension of result<R, S> and it allows an alternative failure to be stored of type P, which can be observed with the member functions .exception() and .assume_exception(). The P state takes precedence during no-value observation over any S state, and it is possible to store S + P simultaneously such that outcome could have any one the states:

  1. R (value_type)

  2. S (error_type)

  3. P (exception_type)

  4. S + P (error_type + exception_type)

Similarly to result, NoValuePolicy defaults to a policy selected according to the characteristics of types S and P:

  1. If .value() called when there is no value_type but there is an exception_type:

  2. If .value() called when there is no value_type but there is an error_type:

  3. If .exception() called when there is no exception_type:

    • If trait::has_exception_ptr_v<P>, or if P is void, do throw bad_outcome_access()

    • If P is none of the above, then it is undefined behaviour [policy::all_narrow]

  4. If .error() called when there is no error_type:

    • If trait::has_error_code_v<S>, or if trait::has_exception_ptr_v<S>, or if S is void, do throw bad_outcome_access()

    • If S is none of the above, then it is undefined behaviour [policy::all_narrow]

Template parameters

  • R — The optional type of the successful result (use void to disable). Cannot be a reference, a in_place_type_t<>, success<>, failure<>, an array, a function or non-destructible.
  • S — The optional type of the first failure result (use void to disable). Must be either void or DefaultConstructible. Cannot be a reference, a in_place_type_t<>, success<>, failure<>, an array, a function or non-destructible.
  • P — The optional type of the second failure result (use void to disable). Must be either void or DefaultConstructible. Cannot be a reference, a in_place_type_t<>, success<>, failure<>, an array, a function or non-destructible.
  • NoValuePolicy — Policy on how to interpret types S and P when a wide observation of a not present value occurs.

Function outcome_v2_xxx::outcome::failure

exception_type failure() const noexcept;

Synthesise exception where possible.

Requires: trait::has_error_code_v<S> and trait::has_exception_ptr_v<P> to be true, else it does not appear.

Returns: A synthesised exception type: if excepted, exception(); if errored, std::make_exception_ptr(std::system_error(error())); otherwise a default constructed exception type.


Function outcome_v2_xxx::outcome::assume_exception

(1) constexpr exception_type& assume_exception() & noexcept;

(2) constexpr exception_type& assume_exception() const & noexcept;

(3) constexpr exception_type&& assume_exception() && noexcept;

(4) constexpr exception_type&& assume_exception() const && noexcept;

Access exception without runtime checks.

Preconditions: The outcome to have an exception state, otherwise it is undefined behaviour.

Returns: Reference to the held exception_type according to overload.


Function outcome_v2_xxx::outcome::exception

(1) constexpr exception_type& exception() &;

(2) constexpr exception_type& exception() const &;

(3) constexpr exception_type&& exception() &&;

(4) constexpr exception_type&& exception() const &&;

Access exception with runtime checks.

Returns: Reference to the held exception_type according to overload.

Requires: The outcome to have an exception state, else whatever NoValuePolicy says ought to happen.


Function outcome_v2_xxx::outcome::assume_error

(1) constexpr error_type& assume_error() & noexcept;

(2) constexpr error_type& assume_error() const & noexcept;

(3) constexpr error_type&& assume_error() && noexcept;

(4) constexpr error_type&& assume_error() const && noexcept;

Access error without runtime checks.

Preconditions: The result to have a failed state, otherwise it is undefined behaviour.

Returns: Reference to the held error_type according to overload.


Function outcome_v2_xxx::outcome::error

(1) constexpr error_type& error() &;

(2) constexpr error_type& error() const &;

(3) constexpr error_type&& error() &&;

(4) constexpr error_type&& error() const &&;

Access error with runtime checks.

Returns: Reference to the held error_type according to overload.

Requires: The result to have a failed state, else whatever NoValuePolicy says ought to happen.


Conversion operator outcome_v2_xxx::outcome::operator bool

explicit operator bool() const noexcept;

Checks if has value.

Returns: True if has value.


Function outcome_v2_xxx::outcome::has_value

constexpr bool has_value() const noexcept;

Checks if has value.

Returns: True if has value.


Function outcome_v2_xxx::outcome::has_error

constexpr bool has_error() const noexcept;

Checks if has error.

Returns: True if has error.


Function outcome_v2_xxx::outcome::has_exception

constexpr bool has_exception() const noexcept;

Checks if has exception.

Returns: True if has exception.


Function outcome_v2_xxx::outcome::has_failure

constexpr bool has_failure() const noexcept;

Checks if has error or exception.

Returns: True if has error or exception.


Function outcome_v2_xxx::outcome::operator==

template <class T, class U, class V>
constexpr bool operator==('hidden' const& o) const noexcept('hidden');

True if equal to the other result.

Effects: If a valid expression to do so, calls the operator== operation on each of the two stored items returning true if both are true. Otherwise returns false.

Throws: Any exception the individual operator== operations might throw.

Parameters

  • o — The other result to compare to.

Function outcome_v2_xxx::outcome::operator==

template <class T>
constexpr bool operator==(success_type<T> const& o) const noexcept('hidden');

True if equal to the success type sugar.

Effects: If a valid expression to do so, calls the operator== operation on the successful item returning true if equal. Otherwise returns false.

Throws: Any exception the operator== operation might throw.

Parameters

  • o — The success type sugar to compare to.

Function outcome_v2_xxx::outcome::operator==

constexpr bool operator==(success_type<void> const& o) const noexcept;

True if equal to the success type sugar.

Effects: If a valid expression to do so, calls the operator== operation on the successful item returning true if equal. Otherwise returns false.

Throws: Any exception the operator== operation might throw.

Parameters

  • o — The success type sugar to compare to.

Function outcome_v2_xxx::outcome::operator==

template <class T>
constexpr bool operator==(failure_type<T, void> const& o) const noexcept('hidden');

True if equal to the failure type sugar.

Effects: If a valid expression to do so, calls the operator== operation on the failure item returning true if equal. Otherwise returns false.

Throws: Any exception the operator== operation might throw.

Parameters

  • o — The failure type sugar to compare to.

Function outcome_v2_xxx::outcome::operator!=

template <class T, class U, class V>
constexpr bool operator!=('hidden' const& o) const noexcept('hidden');

True if not equal to the other result.

Effects: If a valid expression to do so, calls the operator!= operation on each of the two stored items, returning true if any are not equal. Otherwise returns true.

Throws: Any exception the individual operator!= operations might throw.

Parameters

  • o — The other result to compare to.

Function outcome_v2_xxx::outcome::operator!=

template <class T>
constexpr bool operator!=(success_type<T> const& o) const noexcept('hidden');

True if not equal to the success type sugar.

Effects: If a valid expression to do so, calls the operator!= operation on the successful item returning true if not equal. Otherwise returns false.

Throws: Any exception the operator!= operation might throw.

Parameters

  • o — The success type sugar to compare to.

Function outcome_v2_xxx::outcome::operator!=

constexpr bool operator!=(success_type<void> const& o) const noexcept;

True if not equal to the success type sugar.

Effects: If a valid expression to do so, calls the operator!= operation on the successful item returning true if not equal. Otherwise returns false.

Throws: Any exception the operator!= operation might throw.

Parameters

  • o — The success type sugar to compare to.

Function outcome_v2_xxx::outcome::operator!=

template <class T>
constexpr bool operator!=(failure_type<T, void> const& o) const noexcept('hidden');

True if not equal to the failure type sugar.

Effects: If a valid expression to do so, calls the operator!= operation on the failure item returning true if not equal. Otherwise returns false.

Throws: Any exception the operator!= operation might throw.

Parameters

  • o — The failure type sugar to compare to.

Type alias outcome_v2_xxx::outcome::value_type

using value_type = R;

The success type.


Type alias outcome_v2_xxx::outcome::error_type

using error_type = S;

The failure type.


Type alias outcome_v2_xxx::outcome::exception_type

using exception_type = P;

The exception type


Alias template outcome_v2_xxx::outcome::rebind

template <class T, class U = S, class V = P, class W = policy::default_policy<T,U,V>>
using rebind = outcome<T, U, V, W>;

Used to rebind this outcome to a different outcome type


Struct outcome_v2_xxx::outcome::predicate

struct predicate
{
    using base = 'hidden';

    template <class T>static constexpr bool enable_value_converting_constructor = !std::is_same<std::decay_t<T>, outcome>::value && base::template  enable_value_converting_constructor<T>;

    template <class T>static constexpr bool enable_error_converting_constructor = !std::is_same<std::decay_t<T>, outcome>::value && base::template  enable_error_converting_constructor<T>;

    template <class ErrorCondEnum>static constexpr bool enable_error_condition_converting_constructor = !std::is_same<std::decay_t<ErrorCondEnum>, outcome>::value && base::template  enable_error_condition_converting_constructor<ErrorCondEnum>;

    template <class T>static constexpr bool enable_exception_converting_constructor = !std::is_same<std::decay_t<T>, outcome>::value && base::template  enable_exception_converting_constructor<T>;

    template <class T, class U, class V, class W>static constexpr bool enable_compatible_conversion = !std::is_same<outcome<T, U, V, W>, outcome>::value && base::template  enable_compatible_conversion<T, U, V, W>;

    template <class...Args>static constexpr bool enable_inplace_value_constructor = std::is_void<value_type>::value || std::is_constructible<value_type, Args...>::value;

    template <class...Args>static constexpr bool enable_inplace_error_constructor = std::is_void<error_type>::value || std::is_constructible<error_type, Args...>::value;

    template <class...Args>static constexpr bool enable_inplace_exception_constructor = std::is_void<exception_type>::value || std::is_constructible<exception_type, Args...>::value;

    template <class...Args>static constexpr bool enable_inplace_value_error_exception_constructor = base::template  enable_inplace_value_error_exception_constructor<Args...>;

    template <class ... Args>
    using choose_inplace_value_error_exception_constructor = typename base::choose_inplace_value_error_exception_constructor<Args...>;
};

Requirement predicates for outcome.

Unexposed entity outcome_v2_xxx::outcome::predicate::enable_value_converting_constructor

template <class T>static constexpr bool enable_value_converting_constructor = !std::is_same<std::decay_t<T>, outcome>::value && base::template  enable_value_converting_constructor<T>;

Predicate for the value converting constructor to be available.


Unexposed entity outcome_v2_xxx::outcome::predicate::enable_error_converting_constructor

template <class T>static constexpr bool enable_error_converting_constructor = !std::is_same<std::decay_t<T>, outcome>::value && base::template  enable_error_converting_constructor<T>;

Predicate for the error converting constructor to be available.


Unexposed entity outcome_v2_xxx::outcome::predicate::enable_error_condition_converting_constructor

template <class ErrorCondEnum>static constexpr bool enable_error_condition_converting_constructor = !std::is_same<std::decay_t<ErrorCondEnum>, outcome>::value && base::template  enable_error_condition_converting_constructor<ErrorCondEnum>;

Predicate for the error condition converting constructor to be available.


Unexposed entity outcome_v2_xxx::outcome::predicate::enable_compatible_conversion

template <class T, class U, class V, class W>static constexpr bool enable_compatible_conversion = !std::is_same<outcome<T, U, V, W>, outcome>::value && base::template  enable_compatible_conversion<T, U, V, W>;

Predicate for the converting constructor from a compatible input to be available.


Unexposed entity outcome_v2_xxx::outcome::predicate::enable_inplace_value_constructor

template <class...Args>static constexpr bool enable_inplace_value_constructor = std::is_void<value_type>::value || std::is_constructible<value_type, Args...>::value;

Predicate for the inplace construction of value to be available.


Unexposed entity outcome_v2_xxx::outcome::predicate::enable_inplace_error_constructor

template <class...Args>static constexpr bool enable_inplace_error_constructor = std::is_void<error_type>::value || std::is_constructible<error_type, Args...>::value;

Predicate for the inplace construction of error to be available.


Unexposed entity outcome_v2_xxx::outcome::predicate::enable_inplace_exception_constructor

template <class...Args>static constexpr bool enable_inplace_exception_constructor = std::is_void<exception_type>::value || std::is_constructible<exception_type, Args...>::value;

Predicate for the inplace construction of exception to be available.



Type alias outcome_v2_xxx::outcome::value_type_if_enabled

using value_type_if_enabled = std::conditional_t<std::is_same<value_type, error_type>::value || std::is_same<value_type, exception_type>::value, disable_in_place_value_type, value_type>;

Used to disable in place type construction when value_type is ambiguous with error_type or exception_type.


Type alias outcome_v2_xxx::outcome::error_type_if_enabled

using error_type_if_enabled = std::conditional_t<std::is_same<error_type, value_type>::value || std::is_same<error_type, exception_type>::value, disable_in_place_error_type, error_type>;

Used to disable in place type construction when error_type is ambiguous with value_type or exception_type.


Type alias outcome_v2_xxx::outcome::exception_type_if_enabled

using exception_type_if_enabled = std::conditional_t<std::is_same<exception_type, value_type>::value || std::is_same<exception_type, error_type>::value, disable_in_place_exception_type, exception_type>;

Used to disable in place type construction when exception_type is ambiguous with value_type or error_type.


Constructor outcome_v2_xxx::outcome::outcome

template <class T>
constexpr outcome(T&& t) noexcept('hidden');

Converting constructor to a successful outcome.

Effects: Initialises the outcome with a value_type.

Requires: Type T is implicitly constructible to value_type, is not implicitly constructible to error_type, is not implicitly constructible to exception_type and is not outcome<R, S, P> and not in_place_type<>.

Throws: Any exception the construction of value_type(T) might throw.

Parameters

  • t — The value from which to initialise the value_type.

Constructor outcome_v2_xxx::outcome::outcome

template <class T>
constexpr outcome(T&& t) noexcept('hidden');

Converting constructor to an errored outcome.

Effects: Initialises the outcome with a error_type.

Requires: Type T is implicitly constructible to error_type, is not implicitly constructible to value_type, is not implicitly constructible to exception_type, and is not outcome<R, S, P> and not in_place_type<>.

Throws: Any exception the construction of error_type(T) might throw.

Parameters

  • t — The value from which to initialise the error_type.

Constructor outcome_v2_xxx::outcome::outcome

template <class ErrorCondEnum>
constexpr outcome(ErrorCondEnum&& t) noexcept('hidden');

Special error condition converting constructor to an errored outcome.

Effects: Initialises the outcome with a error_type constructed via make_error_code(t).

Requires: std::is_error_condition_enum<ErrorCondEnum> must be true, ErrorCondEnum is not implicitly constructible to value_type, error_type nor exception_type, and is not outcome<R, S, P> and not in_place_type<>; Finally, the expression error_type(make_error_code(ErrorCondEnum())) must be valid.

Throws: Any exception the construction of error_type(make_error_code(t)) might throw.

Parameters

  • t — The error condition from which to initialise the error_type.

Constructor outcome_v2_xxx::outcome::outcome

template <class T>
constexpr outcome(T&& t) noexcept('hidden');

Converting constructor to an excepted outcome.

Effects: Initialises the outcome with a exception_type.

Requires: trait::is_exception_ptr<P> must be true; Type T is implicitly constructible to exception_type, is not implicitly constructible to value_type, is not implicitly constructible to error_type, and is not outcome<R, S, P> and not in_place_type<>.

Throws: Any exception the construction of exception_type(T) might throw.

Parameters

  • t — The value from which to initialise the exception_type.

Constructor outcome_v2_xxx::outcome::outcome

template <class T>
constexpr outcome(T&& o);

Explicit converting constructor from a compatible ValueOrError type.

Effects: Initialises the outcome with the contents of the compatible input.

Requires: That convert::value_or_error<outcome, std::decay_t<T>>{}(std::forward<T>(o)) be available. The default implementation will consume T’s matching the ValueOrError concept type. ValueOrError concept matches any type with a value_type, an error_type, a .value(), an .error() and a .has_value().

Parameters

  • o — The input for which a convert::value_or_error<outcome, std::decay_t<T>>{}(std::forward<T>(o)) is available.

Constructor outcome_v2_xxx::outcome::outcome

template <class T, class U, class V, class W>
constexpr outcome(outcome<T, U, V, W> const& o) noexcept('hidden');

Explicit converting copy constructor from a compatible outcome type.

Effects: Initialises the outcome with a copy of the compatible outcome.

Requires: Both outcome’s value_type, error_type, and exception_type need to be constructible, or the source void.

Throws: Any exception the construction of value_type(T), error_type(U) or exception_type(V) might throw.

Parameters

  • o — The compatible outcome.

Constructor outcome_v2_xxx::outcome::outcome

template <class T, class U, class V, class W>
constexpr outcome(outcome<T, U, V, W>&& o) noexcept('hidden');

Explicit converting move constructor from a compatible outcome type.

Effects: Initialises the outcome with a move of the compatible outcome.

Requires: Both outcome’s value_type, error_type, and exception_type need to be constructible, or the source void.

Throws: Any exception the construction of value_type(T), error_type(U) or exception_type(V) might throw.

Parameters

  • o — The compatible outcome.

Constructor outcome_v2_xxx::outcome::outcome

template <class T, class U, class V>
constexpr outcome(result<T, U, V> const& o) noexcept('hidden');

Explicit converting copy constructor from a compatible result type.

Effects: Initialises the outcome with a copy of the compatible result.

Requires: Both outcome’s value_type and error_type need to be constructible, or the source void.

Throws: Any exception the construction of value_type(T), error_type(U) or exception_type() might throw.

Parameters

  • o — The compatible result.

Constructor outcome_v2_xxx::outcome::outcome

template <class T, class U, class V>
constexpr outcome(result<T, U, V>&& o) noexcept('hidden');

Explicit converting move constructor from a compatible result type.

Effects: Initialises the outcome with a move of the compatible result.

Requires: Both outcome’s value_type and error_type need to be constructible, or the source void.

Throws: Any exception the construction of value_type(T), error_type(U) or exception_type() might throw.

Parameters

  • o — The compatible result.

Constructor outcome_v2_xxx::outcome::outcome

template <class ... Args>
constexpr outcome(in_place_type_t<outcome_v2_xxx::outcome::value_type_if_enabled> _, Args &&... args) noexcept('hidden');

Inplace constructor to a successful value.

Effects: Initialises the outcome with a value_type.

Requires: value_type is void or Args... are constructible to value_type.

Throws: Any exception the construction of value_type(Args...) might throw.

Parameters

  • _ — Tag type to indicate we are doing in place construction of value_type.
  • args — Arguments with which to in place construct.

Constructor outcome_v2_xxx::outcome::outcome

template <class U, class ... Args>
constexpr outcome(in_place_type_t<outcome_v2_xxx::outcome::value_type_if_enabled> _, std::initializer_list<U> il, Args &&... args) noexcept('hidden');

Inplace constructor to a successful value.

Effects: Initialises the outcome with a value_type.

Requires: The initializer list + Args... are constructible to value_type.

Throws: Any exception the construction of value_type(il, Args...) might throw.

Parameters

  • _ — Tag type to indicate we are doing in place construction of value_type.
  • il — An initializer list with which to in place construct.
  • args — Arguments with which to in place construct.

Constructor outcome_v2_xxx::outcome::outcome

template <class ... Args>
constexpr outcome(in_place_type_t<outcome_v2_xxx::outcome::error_type_if_enabled> _, Args &&... args) noexcept('hidden');

Inplace constructor to an unsuccessful error.

Effects: Initialises the outcome with a error_type.

Requires: error_type is void or Args... are constructible to error_type.

Throws: Any exception the construction of error_type(Args...) might throw.

Parameters

  • _ — Tag type to indicate we are doing in place construction of error_type.
  • args — Arguments with which to in place construct.

Constructor outcome_v2_xxx::outcome::outcome

template <class U, class ... Args>
constexpr outcome(in_place_type_t<outcome_v2_xxx::outcome::error_type_if_enabled> _, std::initializer_list<U> il, Args &&... args) noexcept('hidden');

Inplace constructor to an unsuccessful error.

Effects: Initialises the outcome with a error_type.

Requires: The initializer list + Args... are constructible to error_type.

Throws: Any exception the construction of error_type(il, Args...) might throw.

Parameters

  • _ — Tag type to indicate we are doing in place construction of error_type.
  • il — An initializer list with which to in place construct.
  • args — Arguments with which to in place construct.

Constructor outcome_v2_xxx::outcome::outcome

template <class ... Args>
constexpr outcome(in_place_type_t<outcome_v2_xxx::outcome::exception_type_if_enabled>, Args &&... args) noexcept('hidden');

Inplace constructor to an unsuccessful exception.

Effects: Initialises the outcome with an exception_type.

Requires: exception_type is void or Args... are constructible to exception_type.

Throws: Any exception the construction of exception_type(Args...) might throw.

Parameters

  • args — Arguments with which to in place construct.

Constructor outcome_v2_xxx::outcome::outcome

template <class U, class ... Args>
constexpr outcome(in_place_type_t<outcome_v2_xxx::outcome::exception_type_if_enabled>, std::initializer_list<U> il, Args &&... args) noexcept('hidden');

Inplace constructor to an unsuccessful exception.

Effects: Initialises the outcome with an exception_type.

Requires: The initializer list + Args... are constructible to exception_type.

Throws: Any exception the construction of exception_type(il, Args...) might throw.

Parameters

  • il — An initializer list with which to in place construct.
  • args — Arguments with which to in place construct.

Constructor outcome_v2_xxx::outcome::outcome

template <class A1, class A2, class ... Args>
constexpr outcome(A1&& a1, A2&& a2, Args &&... args) noexcept('hidden');

Implicit inplace constructor to successful value, or unsuccessful error, or unsuccessful exception.

Effects: Calls the appropriate in_place_type_t<...> constructor depending on constructibility of args.

Requires: That the args can construct exactly one of value_type or error_type or exception_type.

Throws: Any exception the in_place_type_t<...> constructor might throw.

Parameters

  • args — Arguments with which to in place construct.

Constructor outcome_v2_xxx::outcome::outcome

constexpr outcome(success_type<void> const& o) noexcept('hidden');

Implicit tagged constructor of a successful outcome.

Effects: Initialises the outcome with a default constructed success type.

Requires: value_type to be default constructible, or void.

Throws: Any exception the construction of value_type() might throw.

Parameters

  • o — The compatible success type sugar.

Constructor outcome_v2_xxx::outcome::outcome

template <class T>
constexpr outcome(success_type<T> const& o) noexcept('hidden');

Implicit tagged constructor of a successful outcome.

Effects: Initialises the outcome with a copy of the value in the type sugar.

Requires: Both outcome and success’ value_type need to be constructible. The source cannot be void.

Throws: Any exception the construction of value_type(T) might throw.

Parameters

  • o — The compatible success type sugar.

Constructor outcome_v2_xxx::outcome::outcome

template <class T>
constexpr outcome(success_type<T>&& o) noexcept('hidden');

Implicit tagged constructor of a successful outcome.

Effects: Initialises the outcome with a move of the value in the type sugar.

Requires: Both outcome and success’ value_type need to be constructible. The source cannot be void.

Throws: Any exception the construction of value_type(T) might throw.

Parameters

  • o — The compatible success type sugar.

Constructor outcome_v2_xxx::outcome::outcome

template <class T, class U>
constexpr outcome(failure_type<T, U> const& o) noexcept('hidden');

Implicit tagged constructor of a failure outcome.

Effects: Initialises the outcome with a copy of the error and/or exception in the type sugar.

Requires: Both outcome and failure’s error_type and exception_type need to be constructible, or the source can be void.

Throws: Any exception the construction of error_type(T) and/or exception_type(U) might throw.

Parameters

  • o — The compatible failure type sugar.

Constructor outcome_v2_xxx::outcome::outcome

template <class T, class U>
constexpr outcome(failure_type<T, U>&& o) noexcept('hidden');

Implicit tagged constructor of a failure outcome.

Effects: Initialises the outcome with a copy of the error and/or exception in the type sugar.

Requires: Both outcome and failure’s error_type and exception_type need to be constructible, or the source can be void.

Throws: Any exception the construction of error_type(T) and/or exception_type(U) might throw.

Parameters

  • o — The compatible failure type sugar.

Function outcome_v2_xxx::outcome::operator==

template <class T, class U, class V, class W>
constexpr bool operator==(outcome<T, U, V, W> const& o) const noexcept('hidden');

True if equal to the other outcome.

Effects: If a valid expression to do so, calls the operator== operation on each of the three stored items returning true if both are true. Otherwise returns false.

Throws: Any exception the individual operator== operations might throw.

Parameters

  • o — The other outcome to compare to.

Function outcome_v2_xxx::outcome::operator==

template <class T, class U>
constexpr bool operator==(failure_type<T, U> const& o) const noexcept('hidden');

True if equal to the failure type sugar.

Effects: If a valid expression to do so, calls the operator== operation on the failure items returning true if equal. Otherwise returns false.

Throws: Any exception the operator== operations might throw.

Parameters

  • o — The failure type sugar to compare to.

Function outcome_v2_xxx::outcome::operator!=

template <class T, class U, class V, class W>
constexpr bool operator!=(outcome<T, U, V, W> const& o) const noexcept('hidden');

True if not equal to the other outcome.

Effects: If a valid expression to do so, calls the operator!= operation on each of the three stored items, returning true if any are not equal. Otherwise returns true.

Throws: Any exception the individual operator!= operations might throw.

Parameters

  • o — The other outcome to compare to.

Function outcome_v2_xxx::outcome::operator!=

template <class T, class U>
constexpr bool operator!=(failure_type<T, U> const& o) const noexcept('hidden');

True if not equal to the failure type sugar.

Effects: If a valid expression to do so, calls the operator!= operation on the failure items returning true if not equal. Otherwise returns false.

Throws: Any exception the operator!= operations might throw.

Parameters

  • o — The failure type sugar to compare to.

Function outcome_v2_xxx::outcome::swap

void swap(outcome<R, S, P, NoValuePolicy>& o) noexcept('hidden');

Swaps this result with another result

Effects: Any R and/or S is swapped along with the metadata tracking them.


Function outcome_v2_xxx::outcome::as_failure

failure_type<outcome_v2_xxx::outcome::error_type, outcome_v2_xxx::outcome::exception_type> as_failure() const &;

Returns this outcome as a failure_type with any errored and/or excepted state copied.

Requires: This outcome to have a failed state, else whatever assume_error() would do.


Function outcome_v2_xxx::outcome::as_failure

failure_type<outcome_v2_xxx::outcome::error_type, outcome_v2_xxx::outcome::exception_type> as_failure() &&;

Returns this outcome as a failure_type with any errored and/or excepted state moved.

Requires: This outcome to have a failed state, else whatever assume_error() would do.



Function outcome_v2_xxx::operator==

template <class T, class U, class V, class R, class S, class P, class N>
constexpr bool operator==(result<T, U, V> const& a, outcome<R, S, P, N> const& b) noexcept('hidden');

True if the result is equal to the outcome

Remarks: Implemented as b == a.

Requires: That the expression b == a is a valid expression.

Throws: Any exception that b == a might throw.

Parameters

  • a — The result to compare.
  • b — The outcome to compare.

Function outcome_v2_xxx::operator!=

template <class T, class U, class V, class R, class S, class P, class N>
constexpr bool operator!=(result<T, U, V> const& a, outcome<R, S, P, N> const& b) noexcept('hidden');

True if the result is not equal to the outcome

Remarks: Implemented as b != a.

Requires: That the expression b != a is a valid expression.

Throws: Any exception that b != a might throw.

Parameters

  • a — The result to compare.
  • b — The outcome to compare.

Function outcome_v2_xxx::swap

template <class R, class S, class P, class N>
void swap(outcome<R, S, P, N>& a, outcome<R, S, P, N>& b) noexcept('hidden');

Specialise swap for outcome.

Effects: Calls a.swap(b).


Function outcome_v2_xxx::hooks::override_outcome_exception

template <class R, class S, class P, class NoValuePolicy, class U>
constexpr void override_outcome_exception(outcome<R, S, P, NoValuePolicy>* o, U&& v) noexcept;

Used to set/override an exception during a construction hook implementation.

Effects: Sets the exception of the outcome to the given value.

Parameters

  • o — The outcome you wish to change.
  • v — Exception to be set.