Header file std_error_code.hpp

#include "posix_code.hpp"

#include "win32_code.hpp"

namespace system_error2
{
    using std_error_code = status_code<_error_code_domain<std::error_code, detail::make_std_categories>>;

    template <class error_code_type, class make_categories_type>
    class _error_code_domain;

    constexpr _error_code_domain<std::error_code, detail::make_std_categories> const std_error_code_domain;

    static constexpr _error_code_domain<error_code_type, make_categories_type> const& _error_code_domain<error_code_type, make_categories_type>::get();

    std_error_code make_status_code(std::error_code c) noexcept;
}

Type alias system_error2::std_error_code

using std_error_code = status_code<_error_code_domain<std::error_code, detail::make_std_categories>>;

A wrapper of std::error_code.


Class system_error2::_error_code_domain

template <class error_code_type, class make_categories_type>
class _error_code_domain
: public status_code_domain
{
public:
    using value_type = error_code_type;

    constexpr _error_code_domain(typename _base::unique_id_type id = 0x223a160d20de97b4) noexcept;

    _error_code_domain(const _error_code_domain<error_code_type, make_category_types>&) = default;

    _error_code_domain(_error_code_domain<error_code_type, make_category_types>&&) = default;

    _error_code_domain<error_code_type, make_category_types>& operator=(const _error_code_domain<error_code_type, make_category_types>&) = default;

    _error_code_domain<error_code_type, make_category_types>& operator=(_error_code_domain<error_code_type, make_category_types>&&) = default;

    ~_error_code_domain() = default;

    static constexpr const _error_code_domain<error_code_type, make_category_types>& get();

    virtual system_error2::status_code_domain::string_ref name() const noexcept;

protected:
    virtual bool _do_failure(status_code<void> const& code) const noexcept;

    virtual bool _do_equivalent(status_code<void> const& code1, status_code<void> const& code2) const noexcept;

    virtual system_error2::generic_code _generic_code(status_code<void> const& code) const noexcept;

    virtual system_error2::status_code_domain::string_ref _do_message(status_code<void> const& code) const noexcept;

    virtual void _do_throw_exception(status_code<void> const& code) const;
};

The implementation of the domain for std::error_code error codes.

Type alias system_error2::_error_code_domain::value_type

using value_type = error_code_type;

The value type of the std::error_code code, which is the std::error_code


Constructor system_error2::_error_code_domain::_error_code_domain

constexpr _error_code_domain(typename _base::unique_id_type id = 0x223a160d20de97b4) noexcept;

Default constructor


Function system_error2::_error_code_domain::get

static constexpr const _error_code_domain<error_code_type, make_category_types>& get();

Constexpr singleton getter. Returns constexpr error_code_domain variable.



Variable system_error2::std_error_code_domain

constexpr _error_code_domain<std::error_code, detail::make_std_categories> const std_error_code_domain;

A constexpr source variable for the std::error_code code domain. Returned by _error_code_domain<error_code_type, detail::make_std_categoriesy>::get().