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; }
187 : _M_value(__v), _M_cat(&__cat) { }
189 template<
typename _ErrorCodeEnum,
typename =
typename
192 { *
this = make_error_code(__e); }
206 template<
typename _ErrorCodeEnum>
210 {
return *
this = make_error_code(__e); }
213 value()
const noexcept {
return _M_value; }
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; }
240 make_error_code(errc __e) noexcept
243 #if __cpp_lib_three_way_comparison
244 inline strong_ordering
245 operator<=>(
const error_code& __lhs,
const error_code& __rhs) noexcept
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()); }
286 : _M_value(__v), _M_cat(&__cat) { }
288 template<
typename _ErrorConditionEnum,
typename =
typename
301 template<
typename _ErrorConditionEnum>
304 operator=(_ErrorConditionEnum __e) noexcept
313 value()
const noexcept {
return _M_value; }
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; }
345 {
return (__lhs.category() == __rhs.category()
346 && __lhs.value() == __rhs.value()); }
351 operator==(
const error_code& __lhs,
const error_condition& __rhs) noexcept
353 return (__lhs.category().equivalent(__lhs.value(), __rhs)
354 || __rhs.category().equivalent(__lhs, __rhs.value()));
359 operator==(
const error_condition& __lhs,
360 const error_condition& __rhs) noexcept
362 return (__lhs.category() == __rhs.category()
363 && __lhs.value() == __rhs.value());
366 #if __cpp_lib_three_way_comparison
369 inline strong_ordering
370 operator<=>(
const error_condition& __lhs,
371 const error_condition& __rhs) noexcept
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()));
400 operator!=(
const error_code& __lhs,
const error_code& __rhs) noexcept
401 {
return !(__lhs == __rhs); }
406 operator!=(
const error_code& __lhs,
const error_condition& __rhs) noexcept
407 {
return !(__lhs == __rhs); }
412 operator!=(
const error_condition& __lhs,
const error_code& __rhs) noexcept
413 {
return !(__lhs == __rhs); }
417 operator!=(
const error_condition& __lhs,
418 const error_condition& __rhs) noexcept
419 {
return !(__lhs == __rhs); }
440 :
runtime_error(__what +
": " + __ec.message()), _M_code(__ec) { }
443 :
runtime_error(__what + (
": " + __ec.message())), _M_code(__ec) { }
450 _M_code(__v, __ecat) { }
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);
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
auto_ptr & operator=(auto_ptr &__a)
auto_ptr assignment operator.
const error_category & generic_category() noexcept
Error category for errno error codes.
const error_category & system_category() noexcept
Error category for other error codes defined by the OS.
error_condition make_error_condition(errc __e) noexcept
Create an error_condition representing a standard errc condition.
error_condition make_error_condition(future_errc __errc) noexcept
Overload for make_error_condition.
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.
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.