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; }
183 error_code() noexcept
186 error_code(
int __v,
const error_category& __cat) noexcept
187 : _M_value(__v), _M_cat(&__cat) { }
189 template<
typename _ErrorCodeEnum,
typename =
typename
191 error_code(_ErrorCodeEnum __e) noexcept
192 { *
this = make_error_code(__e); }
195 assign(
int __v,
const error_category& __cat) noexcept
206 template<
typename _ErrorCodeEnum>
210 {
return *
this = make_error_code(__e); }
213 value()
const noexcept {
return _M_value; }
215 const error_category&
216 category()
const noexcept {
return *_M_cat; }
219 default_error_condition()
const noexcept;
221 _GLIBCXX_DEFAULT_ABI_TAG
224 {
return category().message(value()); }
226 explicit operator bool()
const noexcept
227 {
return _M_value != 0; }
232 const error_category* _M_cat;
243 #if __cpp_lib_three_way_comparison
244 inline strong_ordering
247 if (
auto __c = __lhs.category() <=> __rhs.category(); __c != 0)
249 return __lhs.value() <=> __rhs.value();
253 operator<(
const error_code& __lhs,
const error_code& __rhs) noexcept
255 return (__lhs.category() < __rhs.category()
256 || (__lhs.category() == __rhs.category()
257 && __lhs.value() < __rhs.value()));
261 template<
typename _CharT,
typename _Traits>
262 basic_ostream<_CharT, _Traits>&
263 operator<<(basic_ostream<_CharT, _Traits>& __os,
const error_code& __e)
264 {
return (__os << __e.category().name() <<
':' << __e.value()); }
282 error_condition() noexcept
285 error_condition(
int __v,
const error_category& __cat) noexcept
286 : _M_value(__v), _M_cat(&__cat) { }
288 template<
typename _ErrorConditionEnum,
typename =
typename
290 error_condition(_ErrorConditionEnum __e) noexcept
294 assign(
int __v,
const error_category& __cat) noexcept
301 template<
typename _ErrorConditionEnum>
303 <_ErrorConditionEnum>::value, error_condition&>::type
304 operator=(_ErrorConditionEnum __e) noexcept
313 value()
const noexcept {
return _M_value; }
315 const error_category&
316 category()
const noexcept {
return *_M_cat; }
318 _GLIBCXX_DEFAULT_ABI_TAG
321 {
return category().message(value()); }
323 explicit operator bool()
const noexcept
324 {
return _M_value != 0; }
329 const error_category* _M_cat;
345 {
return (__lhs.category() == __rhs.category()
346 && __lhs.value() == __rhs.value()); }
353 return (__lhs.category().equivalent(__lhs.value(), __rhs)
354 || __rhs.category().equivalent(__lhs, __rhs.value()));
362 return (__lhs.category() == __rhs.category()
363 && __lhs.value() == __rhs.value());
366 #if __cpp_lib_three_way_comparison
369 inline strong_ordering
373 if (
auto __c = __lhs.category() <=> __rhs.category(); __c != 0)
375 return __lhs.value() <=> __rhs.value();
384 return (__lhs.category() < __rhs.category()
385 || (__lhs.category() == __rhs.category()
386 && __lhs.value() < __rhs.value()));
394 return (__rhs.category().equivalent(__rhs.value(), __lhs)
395 || __lhs.category().equivalent(__rhs, __lhs.value()));
401 {
return !(__lhs == __rhs); }
407 {
return !(__lhs == __rhs); }
412 operator!=(
const error_condition& __lhs,
const error_code& __rhs) noexcept
413 {
return !(__lhs == __rhs); }
419 {
return !(__lhs == __rhs); }
420 #endif // three_way_comparison
440 :
runtime_error(__what +
": " + __ec.message()), _M_code(__ec) { }
443 :
runtime_error(__what + (
": " + __ec.message())), _M_code(__ec) { }
445 system_error(
int __v,
const error_category& __ecat,
const char* __what)
450 _M_code(__v, __ecat) { }
452 system_error(
int __v,
const error_category& __ecat,
const string& __what)
454 _M_code(__v, __ecat) { }
456 #if __cplusplus >= 201103L
464 code()
const noexcept {
return _M_code; }
467 _GLIBCXX_END_NAMESPACE_VERSION
472 namespace std _GLIBCXX_VISIBILITY(default)
474 _GLIBCXX_BEGIN_NAMESPACE_VERSION
476 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X
482 :
public __hash_base<size_t, error_code>
485 operator()(
const error_code& __e)
const noexcept
487 const size_t __tmp = std::_Hash_impl::hash(__e.value());
488 return std::_Hash_impl::__hash_combine(&__e.category(), __tmp);
491 #endif // _GLIBCXX_COMPATIBILITY_CXX0X
493 #if __cplusplus >= 201703L
499 :
public __hash_base<size_t, error_condition>
504 const size_t __tmp = std::_Hash_impl::hash(__e.value());
505 return std::_Hash_impl::__hash_combine(&__e.category(), __tmp);
510 _GLIBCXX_END_NAMESPACE_VERSION
515 #endif // _GLIBCXX_SYSTEM_ERROR
One of the comparison functors.
Primary class template hash.
error_condition make_error_condition(future_errc __errc) noexcept
Overload for make_error_condition.
An exception type that includes an error_code value.
error_code make_error_code(errc __e) noexcept
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
error_condition make_error_condition(errc __e) noexcept
Create an error_condition representing a standard errc condition.
Define a member typedef type only if a boolean constant is true.
const error_category & generic_category() noexcept
Error category for errno error codes.
bool operator!=(const error_code &__lhs, const error_code &__rhs) noexcept
One of two subclasses of exception.
auto_ptr & operator=(auto_ptr &__a)
auto_ptr assignment operator.
bool operator==(const error_code &__lhs, const error_code &__rhs) noexcept