29 #ifndef _GLIBCXX_SYSTEM_ERROR
30 #define _GLIBCXX_SYSTEM_ERROR 1
32 #pragma GCC system_header
34 #if __cplusplus < 201103L
42 #if __cplusplus > 201703L
46 namespace std _GLIBCXX_VISIBILITY(default)
48 _GLIBCXX_BEGIN_NAMESPACE_VERSION
55 class error_condition;
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;
78 inline namespace _V2 {
100 name()
const noexcept = 0;
106 #if _GLIBCXX_USE_CXX11_ABI
108 _GLIBCXX_DEFAULT_ABI_TAG
110 _M_message(
int)
const;
113 _GLIBCXX_DEFAULT_ABI_TAG
115 message(
int)
const = 0;
118 message(
int)
const = 0;
122 _M_message(
int)
const;
127 default_error_condition(
int __i)
const noexcept;
133 equivalent(
const error_code& __code,
int __i)
const noexcept;
137 {
return this == &__other; }
139 #if __cpp_lib_three_way_comparison
142 {
return std::compare_three_way()(
this, &__rhs); }
146 {
return this != &__other; }
182 error_code() noexcept
185 error_code(
int __v,
const error_category& __cat) noexcept
186 : _M_value(__v), _M_cat(&__cat) { }
188 template<
typename _ErrorCodeEnum,
typename =
typename
190 error_code(_ErrorCodeEnum __e) noexcept
191 { *
this = make_error_code(__e); }
194 assign(
int __v,
const error_category& __cat) noexcept
205 template<
typename _ErrorCodeEnum>
208 operator=(_ErrorCodeEnum __e) noexcept
209 {
return *
this = make_error_code(__e); }
212 value()
const noexcept {
return _M_value; }
214 const error_category&
215 category()
const noexcept {
return *_M_cat; }
218 default_error_condition()
const noexcept;
220 _GLIBCXX_DEFAULT_ABI_TAG
223 {
return category().message(value()); }
225 explicit operator bool()
const noexcept
226 {
return _M_value != 0; }
231 const error_category* _M_cat;
242 #if __cpp_lib_three_way_comparison
243 inline strong_ordering
246 if (
auto __c = __lhs.category() <=> __rhs.category(); __c != 0)
248 return __lhs.value() <=> __rhs.value();
252 operator<(
const error_code& __lhs,
const error_code& __rhs) noexcept
254 return (__lhs.category() < __rhs.category()
255 || (__lhs.category() == __rhs.category()
256 && __lhs.value() < __rhs.value()));
260 template<
typename _CharT,
typename _Traits>
261 basic_ostream<_CharT, _Traits>&
262 operator<<(basic_ostream<_CharT, _Traits>& __os,
const error_code& __e)
263 {
return (__os << __e.category().name() <<
':' << __e.value()); }
280 error_condition() noexcept
283 error_condition(
int __v,
const error_category& __cat) noexcept
284 : _M_value(__v), _M_cat(&__cat) { }
286 template<
typename _ErrorConditionEnum,
typename =
typename
288 error_condition(_ErrorConditionEnum __e) noexcept
292 assign(
int __v,
const error_category& __cat) noexcept
299 template<
typename _ErrorConditionEnum>
301 <_ErrorConditionEnum>::value, error_condition&>::type
302 operator=(_ErrorConditionEnum __e) noexcept
311 value()
const noexcept {
return _M_value; }
313 const error_category&
314 category()
const noexcept {
return *_M_cat; }
316 _GLIBCXX_DEFAULT_ABI_TAG
319 {
return category().message(value()); }
321 explicit operator bool()
const noexcept
322 {
return _M_value != 0; }
327 const error_category* _M_cat;
343 {
return (__lhs.category() == __rhs.category()
344 && __lhs.value() == __rhs.value()); }
351 return (__lhs.category().equivalent(__lhs.value(), __rhs)
352 || __rhs.category().equivalent(__lhs, __rhs.value()));
360 return (__lhs.category() == __rhs.category()
361 && __lhs.value() == __rhs.value());
364 #if __cpp_lib_three_way_comparison
367 inline strong_ordering
371 if (
auto __c = __lhs.category() <=> __rhs.category(); __c != 0)
373 return __lhs.value() <=> __rhs.value();
382 return (__lhs.category() < __rhs.category()
383 || (__lhs.category() == __rhs.category()
384 && __lhs.value() < __rhs.value()));
392 return (__rhs.category().equivalent(__rhs.value(), __lhs)
393 || __lhs.category().equivalent(__rhs, __lhs.value()));
399 {
return !(__lhs == __rhs); }
405 {
return !(__lhs == __rhs); }
410 operator!=(
const error_condition& __lhs,
const error_code& __rhs) noexcept
411 {
return !(__lhs == __rhs); }
417 {
return !(__lhs == __rhs); }
418 #endif // three_way_comparison
438 :
runtime_error(__what +
": " + __ec.message()), _M_code(__ec) { }
441 :
runtime_error(__what + (
": " + __ec.message())), _M_code(__ec) { }
443 system_error(
int __v,
const error_category& __ecat,
const char* __what)
448 _M_code(__v, __ecat) { }
450 system_error(
int __v,
const error_category& __ecat,
const string& __what)
452 _M_code(__v, __ecat) { }
454 #if __cplusplus >= 201103L
462 code()
const noexcept {
return _M_code; }
465 _GLIBCXX_END_NAMESPACE_VERSION
470 namespace std _GLIBCXX_VISIBILITY(default)
472 _GLIBCXX_BEGIN_NAMESPACE_VERSION
474 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X
480 :
public __hash_base<size_t, error_code>
483 operator()(
const error_code& __e)
const noexcept
485 const size_t __tmp = std::_Hash_impl::hash(__e.value());
486 return std::_Hash_impl::__hash_combine(&__e.category(), __tmp);
489 #endif // _GLIBCXX_COMPATIBILITY_CXX0X
491 #if __cplusplus >= 201703L
497 :
public __hash_base<size_t, error_condition>
502 const size_t __tmp = std::_Hash_impl::hash(__e.value());
503 return std::_Hash_impl::__hash_combine(&__e.category(), __tmp);
508 _GLIBCXX_END_NAMESPACE_VERSION
513 #endif // _GLIBCXX_SYSTEM_ERROR
const error_category & system_category() noexcept
Error category for other error codes defined by the OS.
bool operator==(const error_code &__lhs, const error_code &__rhs) noexcept
bool operator==(const error_condition &__lhs, const error_condition &__rhs) noexcept
Define a member typedef type only if a boolean constant is true.
error_code make_error_code(errc __e) noexcept
bool operator!=(const error_condition &__lhs, const error_condition &__rhs) noexcept
error_condition make_error_condition(errc __e) noexcept
Create an error_condition representing a standard errc condition.
bool operator!=(const error_code &__lhs, const error_code &__rhs) noexcept
error_condition make_error_condition(future_errc __errc) noexcept
Overload for make_error_condition.
Primary class template hash.
One of two subclasses of exception.
One of the comparison functors.
const error_category & generic_category() noexcept
Error category for errno error codes.
An exception type that includes an error_code value.