29#ifndef _GLIBCXX_SYSTEM_ERROR
30#define _GLIBCXX_SYSTEM_ERROR 1
32#pragma GCC system_header
34#if __cplusplus < 201103L
42#if __cplusplus > 201703L
46namespace std _GLIBCXX_VISIBILITY(default)
48_GLIBCXX_BEGIN_NAMESPACE_VERSION
59 template<
typename _Tp>
63 template<
typename _Tp>
70#if __cplusplus > 201402L
71 template <
typename _Tp>
72 inline constexpr bool is_error_code_enum_v =
73 is_error_code_enum<_Tp>::value;
74 template <
typename _Tp>
75 inline constexpr bool is_error_condition_enum_v =
76 is_error_condition_enum<_Tp>::value;
80_GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(_V2)
107 constexpr error_category()
noexcept =
default;
109 virtual ~error_category();
111 error_category(
const error_category&) =
delete;
112 error_category& operator=(
const error_category&) =
delete;
122#if _GLIBCXX_USE_CXX11_ABI
124 _GLIBCXX_DEFAULT_ABI_TAG
126 _M_message(
int)
const;
130 _GLIBCXX_DEFAULT_ABI_TAG
139 _M_message(
int)
const;
159 {
return this == &__other; }
162#if __cpp_lib_three_way_comparison
166 {
return std::compare_three_way()(
this, &__rhs); }
169 operator<(
const error_category& __other)
const noexcept
174 {
return this != &__other; }
181 [[__nodiscard__, __gnu__::__const__]]
182 const error_category&
186 [[__nodiscard__, __gnu__::__const__]]
192_GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)
224 error_code() noexcept
225 : _M_value(0), _M_cat(&system_category()) { }
228 : _M_value(__v), _M_cat(&__cat) { }
230 template<
typename _ErrorCodeEnum,
typename =
typename
232 error_code(_ErrorCodeEnum __e)
noexcept
234 using __adl_only::make_error_code;
247 { assign(0, system_category()); }
250 template<
typename _ErrorCodeEnum>
253 operator=(_ErrorCodeEnum __e)
noexcept
259 value() const noexcept {
return _M_value; }
271 _GLIBCXX_DEFAULT_ABI_TAG
278 explicit operator bool() const noexcept
279 {
return _M_value != 0; }
300 {
return error_code(
static_cast<int>(__e), generic_category()); }
310#if __cpp_lib_three_way_comparison
312 inline strong_ordering
315 if (
auto __c = __lhs.category() <=> __rhs.category(); __c != 0)
317 return __lhs.value() <=> __rhs.value();
321 operator<(
const error_code& __lhs,
const error_code& __rhs)
noexcept
323 return (__lhs.category() < __rhs.category()
324 || (__lhs.category() == __rhs.category()
325 && __lhs.value() < __rhs.value()));
334 template<
typename _CharT,
typename _Traits>
356 : _M_value(0), _M_cat(&generic_category()) { }
360 : _M_value(__v), _M_cat(&__cat) { }
362 template<
typename _ErrorConditionEnum,
typename =
typename
366 using __adl_only::make_error_condition;
379 template<
typename _ErrorConditionEnum>
382 operator=(_ErrorConditionEnum __e)
noexcept
388 {
assign(0, generic_category()); }
395 value() const noexcept {
return _M_value; }
403 _GLIBCXX_DEFAULT_ABI_TAG
410 explicit operator bool() const noexcept
411 {
return _M_value != 0; }
430 inline error_condition
447 return __lhs.category() == __rhs.category()
448 && __lhs.value() == __rhs.value();
463 return __lhs.category().equivalent(__lhs.value(), __rhs)
464 || __rhs.category().equivalent(__lhs, __rhs.value());
479 return __lhs.category() == __rhs.category()
480 && __lhs.value() == __rhs.value();
491#if __cpp_lib_three_way_comparison
493 inline strong_ordering
497 if (
auto __c = __lhs.category() <=> __rhs.category(); __c != 0)
499 return __lhs.value() <=> __rhs.value();
506 return (__lhs.category() < __rhs.category()
507 || (__lhs.category() == __rhs.category()
508 && __lhs.value() < __rhs.value()));
515 return (__rhs.category().equivalent(__rhs.value(), __lhs)
516 || __lhs.category().equivalent(__rhs, __lhs.value()));
521 operator!=(
const error_code& __lhs,
const error_code& __rhs)
noexcept
522 {
return !(__lhs == __rhs); }
527 {
return !(__lhs == __rhs); }
532 {
return !(__lhs == __rhs); }
538 {
return !(__lhs == __rhs); }
561 system_error(
error_code __ec,
const string& __what)
564 system_error(
error_code __ec,
const char* __what)
567 system_error(
int __v,
const error_category& __ecat,
const char* __what)
568 : system_error(
error_code(__v, __ecat), __what) { }
572 _M_code(__v, __ecat) { }
574 system_error(
int __v,
const error_category& __ecat,
const string& __what)
576 _M_code(__v, __ecat) { }
578#if __cplusplus >= 201103L
579 system_error (
const system_error &) =
default;
580 system_error &operator= (
const system_error &) =
default;
583 virtual ~system_error()
noexcept;
586 code()
const noexcept {
return _M_code; }
589_GLIBCXX_END_NAMESPACE_VERSION
594namespace std _GLIBCXX_VISIBILITY(default)
596_GLIBCXX_BEGIN_NAMESPACE_VERSION
598#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
604 :
public __hash_base<size_t, error_code>
607 operator()(
const error_code& __e)
const noexcept
609 const size_t __tmp = std::_Hash_impl::hash(__e.
value());
610 return std::_Hash_impl::__hash_combine(&__e.
category(), __tmp);
615#if __cplusplus >= 201703L
621 :
public __hash_base<size_t, error_condition>
626 const size_t __tmp = std::_Hash_impl::hash(__e.
value());
627 return std::_Hash_impl::__hash_combine(&__e.
category(), __tmp);
632_GLIBCXX_END_NAMESPACE_VERSION
bool operator==(const error_condition &__lhs, const error_condition &__rhs) noexcept
const error_category & system_category() noexcept
Error category for other error codes defined by the OS.
bool operator<(const error_condition &__lhs, const error_condition &__rhs) noexcept
bool operator==(const error_code &__lhs, const error_condition &__rhs) noexcept
bool operator<(const error_code &__lhs, const error_code &__rhs) noexcept
error_code make_error_code(errc __e) noexcept
bool operator==(const error_code &__lhs, const error_code &__rhs) noexcept
error_condition make_error_condition(errc __e) noexcept
const error_category & generic_category() noexcept
Error category for errno error codes.
error_condition make_error_condition(future_errc __errc) noexcept
Overload of make_error_condition for future_errc.
error_code make_error_code(future_errc __errc) noexcept
Overload of make_error_code for future_errc.
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
ISO C++ entities toplevel namespace is std.
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
Template class basic_ostream.
One of two subclasses of exception.
runtime_error(const string &__arg)
Primary class template hash.
virtual error_condition default_error_condition(int __i) const noexcept
Return an error_condition corresponding to i in this category.
bool operator<(const error_category &__other) const noexcept
Ordered comparison that defines a total order for error categories.
virtual bool equivalent(int __i, const error_condition &__cond) const noexcept
Test whether cond corresponds to i for this category.
virtual bool equivalent(const error_code &__code, int __i) const noexcept
Test whether code corresponds to i for this category.
virtual string message(int) const =0
A description of the error condition corresponding to the number.
virtual const char * name() const noexcept=0
A string that identifies the error category.
bool operator==(const error_category &__other) const noexcept
An error_category only compares equal to itself.
const error_category & category() const noexcept
The error category that this error belongs to.
int value() const noexcept
The error value.
string message() const
The category's description of the value.
error_condition default_error_condition() const noexcept
An error_condition for this error's category and value.
const error_category & category() const noexcept
The error category that this error belongs to.
error_condition(int __v, const error_category &__cat) noexcept
Initialize with the specified value and category.
int value() const noexcept
The error value.
error_condition() noexcept
Initialize with a zero (no error) value and the generic category.
string message() const
The category's description of the value.
void assign(int __v, const error_category &__cat) noexcept
Set the value and category.
void clear() noexcept
Reset the value and category to the default-constructed state.
An exception type that includes an error_code value.
Define a member typedef type only if a boolean constant is true.
One of the comparison functors.