error_code throw as system_error (Result)

Header file result_error_code_throw_as_system_error.hpp

#include "detail/common.hpp"

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

Struct outcome_v2_xxx::policy::error_code_throw_as_system_error

template <class T, class EC>
struct error_code_throw_as_system_error<T, EC, void>
{
    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 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:

  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 outcome_v2_xxx::policy::throw_bad_result_access::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 outcome_v2_xxx::policy::throw_bad_result_access::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 outcome_v2_xxx::policy::throw_bad_result_access::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 outcome_v2_xxx::policy::error_code_throw_as_system_error::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 outcome_v2_xxx::policy::error_code_throw_as_system_error::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_result_access.