error_code throw as system_error (Outcome)

Header file outcome_error_code_throw_as_system_error.hpp

#include "result_error_code_throw_as_system_error.hpp"

namespace outcome_v2_xxx
{
    namespace policy
    {
        template <class T, class EC, class E>
        struct error_code_throw_as_system_error;
    }
}

Struct outcome_v2_xxx::policy::error_code_throw_as_system_error

template <class T, class EC, class E>
struct error_code_throw_as_system_error
{
    template <class Impl>
    static constexpr void wide_value_check(Impl&& self);

    template <class Impl>
    static constexpr void wide_error_check(Impl&& self);

    template <class Impl>
    static constexpr void wide_exception_check(Impl&& self);

    template <class Impl>
    static constexpr void narrow_value_check(Impl&& self) noexcept;

    template <class Impl>
    static constexpr void narrow_error_check(Impl&& self) noexcept;

    template <class Impl>
    static constexpr void narrow_exception_check(Impl&& self) noexcept;
};

Policy interpreting EC as a type for which trait::has_error_code_v<EC> is true.

Any wide attempt to access the successful state where there is none causes an attempt to rethrow E if trait::has_exception_ptr_v<E> is true, else:

  1. If trait::has_error_payload_v<EC> is true, it calls an ADL discovered free function throw_as_system_error_with_payload(.error()).

  2. If trait::has_error_payload_v<EC> is false, it calls OUTCOME_THROW_EXCEPTION(std::system_error(policy::error_code(.error())))

Function narrow_value_check

template <class Impl>
static constexpr void narrow_value_check(Impl&& self) noexcept;

Performs a narrow check of state, used in the assume_value() functions.

Effects: None.


Function narrow_error_check

template <class Impl>
static constexpr void narrow_error_check(Impl&& self) noexcept;

Performs a narrow check of state, used in the assume_error() functions

Effects: None.


Function narrow_exception_check

template <class Impl>
static constexpr void narrow_exception_check(Impl&& self) noexcept;

Performs a narrow check of state, used in the assume_exception() functions

Effects: None.


Function wide_value_check

template <class Impl>
static constexpr void wide_value_check(Impl&& self);

Performs a wide check of state, used in the value() functions.

Effects: See description of class for effects.


Function wide_error_check

template <class Impl>
static constexpr void wide_error_check(Impl&& self);

Performs a wide check of state, used in the error() functions

Effects: If result does not have an error, it throws bad_outcome_access.


Function wide_exception_check

template <class Impl>
static constexpr void wide_exception_check(Impl&& self);

Performs a wide check of state, used in the exception() functions

Effects: If result does not have an exception, it throws bad_outcome_access.