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 inline namespace _V2 {
100 constexpr error_category()
noexcept =
default;
102 virtual ~error_category();
104 error_category(
const error_category&) =
delete;
105 error_category& operator=(
const error_category&) =
delete;
108 name()
const noexcept = 0;
114#if _GLIBCXX_USE_CXX11_ABI
116 _GLIBCXX_DEFAULT_ABI_TAG
118 _M_message(
int)
const;
121 _GLIBCXX_DEFAULT_ABI_TAG
123 message(
int)
const = 0;
126 message(
int)
const = 0;
130 _M_message(
int)
const;
135 default_error_condition(
int __i)
const noexcept;
141 equivalent(
const error_code& __code,
int __i)
const noexcept;
144 operator==(
const error_category& __other)
const noexcept
145 {
return this == &__other; }
147#if __cpp_lib_three_way_comparison
149 operator<=>(
const error_category& __rhs)
const noexcept
150 {
return std::compare_three_way()(
this, &__rhs); }
153 operator!=(
const error_category& __other)
const noexcept
154 {
return this != &__other; }
157 operator<(
const error_category& __other)
const noexcept
199 error_code() noexcept
203 : _M_value(__v), _M_cat(&__cat) { }
205 template<
typename _ErrorCodeEnum,
typename =
typename
207 error_code(_ErrorCodeEnum __e)
noexcept
208 { *
this = make_error_code(__e); }
222 template<
typename _ErrorCodeEnum>
225 operator=(_ErrorCodeEnum __e)
noexcept
226 {
return *
this = make_error_code(__e); }
229 value()
const noexcept {
return _M_value; }
232 category()
const noexcept {
return *_M_cat; }
235 default_error_condition()
const noexcept;
237 _GLIBCXX_DEFAULT_ABI_TAG
240 {
return category().message(value()); }
242 explicit operator bool()
const noexcept
243 {
return _M_value != 0; }
256 make_error_code(errc __e)
noexcept
259#if __cpp_lib_three_way_comparison
260 inline strong_ordering
261 operator<=>(
const error_code& __lhs,
const error_code& __rhs)
noexcept
263 if (
auto __c = __lhs.category() <=> __rhs.category(); __c != 0)
265 return __lhs.value() <=> __rhs.value();
269 operator<(
const error_code& __lhs,
const error_code& __rhs)
noexcept
271 return (__lhs.category() < __rhs.category()
272 || (__lhs.category() == __rhs.category()
273 && __lhs.value() < __rhs.value()));
277 template<
typename _CharT,
typename _Traits>
278 basic_ostream<_CharT, _Traits>&
279 operator<<(basic_ostream<_CharT, _Traits>& __os,
const error_code& __e)
280 {
return (__os << __e.category().name() <<
':' << __e.value()); }
284 error_condition make_error_condition(errc)
noexcept;
297 class error_condition
300 error_condition() noexcept
301 : _M_value(0), _M_cat(&generic_category()) { }
304 : _M_value(__v), _M_cat(&__cat) { }
306 template<
typename _ErrorConditionEnum,
typename =
typename
308 error_condition(_ErrorConditionEnum __e)
noexcept
319 template<
typename _ErrorConditionEnum>
321 <_ErrorConditionEnum>::value, error_condition&>
::type
322 operator=(_ErrorConditionEnum __e)
noexcept
327 { assign(0, generic_category()); }
331 value()
const noexcept {
return _M_value; }
334 category()
const noexcept {
return *_M_cat; }
336 _GLIBCXX_DEFAULT_ABI_TAG
339 {
return category().message(value()); }
341 explicit operator bool()
const noexcept
342 {
return _M_value != 0; }
363 {
return (__lhs.category() == __rhs.category()
364 && __lhs.value() == __rhs.value()); }
368 operator==(
const error_code& __lhs,
const error_condition& __rhs)
noexcept
370 return (__lhs.category().equivalent(__lhs.value(), __rhs)
371 || __rhs.category().equivalent(__lhs, __rhs.value()));
376 operator==(
const error_condition& __lhs,
377 const error_condition& __rhs)
noexcept
379 return (__lhs.category() == __rhs.category()
380 && __lhs.value() == __rhs.value());
383#if __cpp_lib_three_way_comparison
386 inline strong_ordering
387 operator<=>(
const error_condition& __lhs,
388 const error_condition& __rhs)
noexcept
390 if (
auto __c = __lhs.category() <=> __rhs.category(); __c != 0)
392 return __lhs.value() <=> __rhs.value();
399 const error_condition& __rhs)
noexcept
401 return (__lhs.category() < __rhs.category()
402 || (__lhs.category() == __rhs.category()
403 && __lhs.value() < __rhs.value()));
410 return (__rhs.category().equivalent(__rhs.value(), __lhs)
411 || __lhs.category().equivalent(__rhs, __lhs.value()));
416 operator!=(
const error_code& __lhs,
const error_code& __rhs)
noexcept
417 {
return !(__lhs == __rhs); }
421 operator!=(
const error_code& __lhs,
const error_condition& __rhs)
noexcept
422 {
return !(__lhs == __rhs); }
426 operator!=(
const error_condition& __lhs,
const error_code& __rhs)
noexcept
427 {
return !(__lhs == __rhs); }
431 operator!=(
const error_condition& __lhs,
432 const error_condition& __rhs)
noexcept
433 {
return !(__lhs == __rhs); }
455 system_error(
error_code __ec,
const string& __what)
456 :
runtime_error(__what +
": " + __ec.message()), _M_code(__ec) { }
458 system_error(
error_code __ec,
const char* __what)
459 :
runtime_error(__what + (
": " + __ec.message())), _M_code(__ec) { }
461 system_error(
int __v,
const error_category& __ecat,
const char* __what)
462 : system_error(
error_code(__v, __ecat), __what) { }
466 _M_code(__v, __ecat) { }
468 system_error(
int __v,
const error_category& __ecat,
const string& __what)
470 _M_code(__v, __ecat) { }
472#if __cplusplus >= 201103L
473 system_error (
const system_error &) =
default;
474 system_error &operator= (
const system_error &) =
default;
477 virtual ~system_error()
noexcept;
480 code()
const noexcept {
return _M_code; }
483_GLIBCXX_END_NAMESPACE_VERSION
488namespace std _GLIBCXX_VISIBILITY(default)
490_GLIBCXX_BEGIN_NAMESPACE_VERSION
492#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
498 :
public __hash_base<size_t, error_code>
501 operator()(
const error_code& __e)
const noexcept
503 const size_t __tmp = std::_Hash_impl::hash(__e.value());
504 return std::_Hash_impl::__hash_combine(&__e.category(), __tmp);
509#if __cplusplus >= 201703L
515 :
public __hash_base<size_t, error_condition>
520 const size_t __tmp = std::_Hash_impl::hash(__e.value());
521 return std::_Hash_impl::__hash_combine(&__e.category(), __tmp);
526_GLIBCXX_END_NAMESPACE_VERSION
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
Define an ordering for error_condition objects.
error_condition make_error_condition(errc __e) noexcept
Create an error_condition representing a standard errc condition.
const error_category & generic_category() noexcept
Error category for errno error codes.
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.
One of two subclasses of exception.
runtime_error(const string &__arg) _GLIBCXX_TXN_SAFE
Primary class template hash.
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.