29#ifndef _GLIBCXX_SYSTEM_ERROR
30#define _GLIBCXX_SYSTEM_ERROR 1
33#pragma GCC system_header
38#if __cplusplus < 201103L
46#if __cplusplus > 201703L
50namespace std _GLIBCXX_VISIBILITY(default)
52_GLIBCXX_BEGIN_NAMESPACE_VERSION
63 template<
typename _Tp>
67 template<
typename _Tp>
74#if __cplusplus > 201402L
75 template <
typename _Tp>
76 inline constexpr bool is_error_code_enum_v =
77 is_error_code_enum<_Tp>::value;
78 template <
typename _Tp>
79 inline constexpr bool is_error_condition_enum_v =
80 is_error_condition_enum<_Tp>::value;
84_GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(_V2)
111 constexpr error_category()
noexcept =
default;
113 virtual ~error_category();
115 error_category(
const error_category&) =
delete;
116 error_category& operator=(
const error_category&) =
delete;
126#if _GLIBCXX_USE_CXX11_ABI
128 _GLIBCXX_DEFAULT_ABI_TAG
130 _M_message(
int)
const;
134 _GLIBCXX_DEFAULT_ABI_TAG
143 _M_message(
int)
const;
163 {
return this == &__other; }
166#if __cpp_lib_three_way_comparison
169 operator<=>(
const error_category& __rhs)
const noexcept
170 {
return std::compare_three_way()(
this, &__rhs); }
178 {
return this != &__other; }
185 [[__nodiscard__, __gnu__::__const__]]
190 [[__nodiscard__, __gnu__::__const__]]
196_GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)
227 template<
typename _ErrorCodeEnum>
229 = __enable_if_t<is_error_code_enum<_ErrorCodeEnum>::value>;
232 error_code() noexcept
233 : _M_value(0), _M_cat(&system_category()) { }
236 : _M_value(__v), _M_cat(&__cat) { }
239 template<
typename _ErrorCodeEnum,
240 typename = _Check<_ErrorCodeEnum>>
241 error_code(_ErrorCodeEnum __e)
noexcept
243 using __adl_only::make_error_code;
259 { assign(0, system_category()); }
264 value() const noexcept {
return _M_value; }
269 category() const noexcept {
return *_M_cat; }
276 _GLIBCXX_DEFAULT_ABI_TAG
283 explicit operator bool() const noexcept
284 {
return _M_value != 0; }
305 {
return error_code(
static_cast<int>(__e), generic_category()); }
315#if __cpp_lib_three_way_comparison
317 inline strong_ordering
318 operator<=>(
const error_code& __lhs,
const error_code& __rhs)
noexcept
320 if (
auto __c = __lhs.category() <=> __rhs.category(); __c != 0)
322 return __lhs.value() <=> __rhs.value();
328 return (__lhs.category() < __rhs.category()
329 || (__lhs.category() == __rhs.category()
330 && __lhs.value() < __rhs.value()));
339 template<
typename _CharT,
typename _Traits>
340 basic_ostream<_CharT, _Traits>&
341 operator<<(basic_ostream<_CharT, _Traits>& __os,
const error_code& __e)
342 {
return (__os << __e.category().name() <<
':' << __e.value()); }
358 template<
typename _ErrorConditionEnum>
360 = __enable_if_t<is_error_condition_enum<_ErrorConditionEnum>::value>;
365 : _M_value(0), _M_cat(&generic_category()) { }
369 : _M_value(__v), _M_cat(&__cat) { }
372 template<
typename _ErrorConditionEnum,
373 typename = _Check<_ErrorConditionEnum>>
376 using __adl_only::make_error_condition;
394 {
assign(0, generic_category()); }
401 value() const noexcept {
return _M_value; }
406 category() const noexcept {
return *_M_cat; }
409 _GLIBCXX_DEFAULT_ABI_TAG
416 explicit operator bool() const noexcept
417 {
return _M_value != 0; }
436 inline error_condition
453 return __lhs.category() == __rhs.category()
454 && __lhs.value() == __rhs.value();
469 return __lhs.category().equivalent(__lhs.value(), __rhs)
470 || __rhs.category().equivalent(__lhs, __rhs.value());
485 return __lhs.category() == __rhs.category()
486 && __lhs.value() == __rhs.value();
497#if __cpp_lib_three_way_comparison
499 inline strong_ordering
503 if (
auto __c = __lhs.category() <=> __rhs.category(); __c != 0)
505 return __lhs.value() <=> __rhs.value();
512 return (__lhs.category() < __rhs.category()
513 || (__lhs.category() == __rhs.category()
514 && __lhs.value() < __rhs.value()));
519 operator==(
const error_condition& __lhs,
const error_code& __rhs)
noexcept
521 return (__rhs.category().equivalent(__rhs.value(), __lhs)
522 || __lhs.category().equivalent(__rhs, __lhs.value()));
528 {
return !(__lhs == __rhs); }
533 {
return !(__lhs == __rhs); }
538 {
return !(__lhs == __rhs); }
544 {
return !(__lhs == __rhs); }
567 system_error(
error_code __ec,
const string& __what)
570 system_error(
error_code __ec,
const char* __what)
573 system_error(
int __v,
const error_category& __ecat,
const char* __what)
574 : system_error(
error_code(__v, __ecat), __what) { }
578 _M_code(__v, __ecat) { }
580 system_error(
int __v,
const error_category& __ecat,
const string& __what)
582 _M_code(__v, __ecat) { }
584#if __cplusplus >= 201103L
585 system_error (
const system_error &) =
default;
586 system_error &operator= (
const system_error &) =
default;
589 virtual ~system_error()
noexcept;
592 code()
const noexcept {
return _M_code; }
595_GLIBCXX_END_NAMESPACE_VERSION
600namespace std _GLIBCXX_VISIBILITY(default)
602_GLIBCXX_BEGIN_NAMESPACE_VERSION
604#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
610 :
public __hash_base<size_t, error_code>
613 operator()(
const error_code& __e)
const noexcept
615 const size_t __tmp = std::_Hash_impl::hash(__e.
value());
616 return std::_Hash_impl::__hash_combine(&__e.
category(), __tmp);
621#if __cplusplus >= 201703L
627 :
public __hash_base<size_t, error_condition>
632 const size_t __tmp = std::_Hash_impl::hash(__e.
value());
633 return std::_Hash_impl::__hash_combine(&__e.
category(), __tmp);
638_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.
strong_ordering operator<=>(const error_code &__lhs, const error_code &__rhs) noexcept
bool operator==(const error_code &__lhs, const error_condition &__rhs) noexcept
strong_ordering operator<=>(const error_condition &__lhs, const error_condition &__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.
__bool_constant< true > true_type
The type used as a compile-time boolean with true value.
__bool_constant< 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.
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.
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.
strong_ordering operator<=>(const error_category &__rhs) const noexcept
Ordered comparison that defines a total order for error categories.
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.
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.
One of the comparison functors.