1#ifndef NEFORCE_CORE_EXCEPTION_ERROR_CODE_HPP__
2#define NEFORCE_CORE_EXCEPTION_ERROR_CODE_HPP__
13NEFORCE_BEGIN_NAMESPACE__
80 NEFORCE_NODISCARD
int value() const noexcept {
return value_; }
86 NEFORCE_NODISCARD
errc error() const noexcept {
return static_cast<errc>(value_); }
99 return category_->default_error_condition(value_);
106 NEFORCE_NODISCARD
string message()
const {
return category_->message(value_); }
112 explicit operator bool() const noexcept {
return value_ != 0; }
115 return category_ == rhs.category_ && value_ == rhs.value_;
117 NEFORCE_NODISCARD
bool less_than(
const error_code& rhs)
const noexcept {
118 if (*category_ < *rhs.category_) {
121 if (*rhs.category_ < *category_) {
124 return value_ < rhs.value_;
133 return category_->equivalent(value_, cond) || cond.category().equivalent(*
this, cond.value());
143 NEFORCE_NODISCARD
size_t to_hash() const noexcept {
return hash_combine_all(category_, value_); }
161NEFORCE_END_NAMESPACE__
bool operator==(const error_condition &cond) const noexcept
与错误条件进行等价比较
string message() const
获取错误描述信息
int value() const noexcept
获取错误码值
bool operator!=(const error_condition &cond) const noexcept
与错误条件进行不等价比较
void clear() noexcept
清空错误码
void assign(int val, const error_category &cat) noexcept
赋值错误码值和类别
error_condition default_error_condition() const noexcept
获取对应的默认错误条件
const error_category & category() const noexcept
获取错误类别
error_code() noexcept=default
默认构造函数
errc error() const noexcept
获取对应 errc 枚举值
error_code(errc e) noexcept
从 errc 枚举构造
const error_category & generic_category() noexcept
获取通用错误类别单例
error_code last_error() noexcept
获取当前系统错误码
const error_category & system_category() noexcept
获取系统错误类别单例
error_code make_error_code(errc e) noexcept
从 errc 枚举创建错误码
constexpr size_t hash_combine_all(const Types &... values) noexcept
混合多个哈希值