Header file posix_code.hpp

#include "quick_status_code_from_enum.hpp"

namespace system_error2
{
    using posix_code = status_code<system_error2::_posix_code_domain>;

    using posix_error = status_error<system_error2::_posix_code_domain>;

    namespace mixins
    {
        template <class Base>
        struct mixin<Base, _posix_code_domain>;
    }

    class _posix_code_domain;

    constexpr system_error2::_posix_code_domain const posix_code_domain;

    static constexpr system_error2::_posix_code_domain const& _posix_code_domain::get();

    namespace mixins
    {
        static system_error2::posix_code mixin<Base, system_error2::_posix_code_domain>::current() noexcept;
    }
}

Type alias system_error2::posix_code

using posix_code = status_code<system_error2::_posix_code_domain>;

A POSIX error code, those returned by errno.


Type alias system_error2::posix_error

using posix_error = status_error<system_error2::_posix_code_domain>;

A specialisation of status_error for the POSIX error code domain.


Class system_error2::_posix_code_domain

class _posix_code_domain
: public status_code_domain
{
public:
    using value_type = int;

    constexpr _posix_code_domain(typename _base::unique_id_type id = 0xa59a56fe5f310933) noexcept;

    _posix_code_domain(system_error2::_posix_code_domain const&) = default;

    _posix_code_domain(system_error2::_posix_code_domain&&) = default;

    system_error2::_posix_code_domain& operator=(system_error2::_posix_code_domain const&) = default;

    system_error2::_posix_code_domain& operator=(system_error2::_posix_code_domain&&) = default;

    ~_posix_code_domain() = default;

    static constexpr system_error2::_posix_code_domain const& 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 POSIX error codes, those returned by errno.

Type alias system_error2::_posix_code_domain::value_type

using value_type = int;

The value type of the POSIX code, which is an int


Constructor system_error2::_posix_code_domain::_posix_code_domain

constexpr _posix_code_domain(typename _base::unique_id_type id = 0xa59a56fe5f310933) noexcept;

Default constructor


Function system_error2::_posix_code_domain::get

static constexpr system_error2::_posix_code_domain const& get();

Constexpr singleton getter. Returns constexpr posix_code_domain variable.



Variable system_error2::posix_code_domain

constexpr system_error2::_posix_code_domain const posix_code_domain;

A constexpr source variable for the POSIX code domain, which is that of errno. Returned by _posix_code_domain::get().