29 #ifndef _GLIBCXX_SYSTEM_ERROR
30 #define _GLIBCXX_SYSTEM_ERROR 1
32 #pragma GCC system_header
34 #if __cplusplus < 201103L
43 namespace std _GLIBCXX_VISIBILITY(default)
45 _GLIBCXX_BEGIN_NAMESPACE_VERSION
48 class error_condition;
52 template<
typename _Tp>
56 template<
typename _Tp>
63 #if __cplusplus > 201402L
64 template <
typename _Tp>
65 inline constexpr
bool is_error_code_enum_v =
66 is_error_code_enum<_Tp>::value;
67 template <
typename _Tp>
68 inline constexpr
bool is_error_condition_enum_v =
69 is_error_condition_enum<_Tp>::value;
71 inline namespace _V2 {
91 #if _GLIBCXX_USE_CXX11_ABI
93 _GLIBCXX_DEFAULT_ABI_TAG
95 _M_message(
int)
const;
98 _GLIBCXX_DEFAULT_ABI_TAG
100 message(
int)
const = 0;
103 message(
int)
const = 0;
107 _M_message(
int)
const;
112 default_error_condition(
int __i)
const noexcept;
126 {
return this == &__other; }
130 {
return this != &__other; }
141 template<typename _Tp>
148 error_code() noexcept
149 : _M_value(0), _M_cat(&system_category()) { }
151 error_code(
int __v,
const error_category& __cat) noexcept
152 : _M_value(__v), _M_cat(&__cat) { }
154 template<
typename _ErrorCodeEnum,
typename =
typename
156 error_code(_ErrorCodeEnum __e) noexcept
157 { *
this = make_error_code(__e); }
160 assign(
int __v,
const error_category& __cat) noexcept
168 { assign(0, system_category()); }
171 template<
typename _ErrorCodeEnum>
174 operator=(_ErrorCodeEnum __e) noexcept
175 {
return *
this = make_error_code(__e); }
178 value()
const noexcept {
return _M_value; }
180 const error_category&
181 category()
const noexcept {
return *_M_cat; }
184 default_error_condition()
const noexcept;
186 _GLIBCXX_DEFAULT_ABI_TAG
189 {
return category().message(value()); }
191 explicit operator bool()
const noexcept
192 {
return _M_value != 0; }
196 friend class hash<error_code>;
199 const error_category* _M_cat;
205 {
return error_code(static_cast<int>(__e), generic_category()); }
208 operator<(
const error_code& __lhs,
const error_code& __rhs)
noexcept
210 return (__lhs.category() < __rhs.category()
211 || (__lhs.category() == __rhs.category()
212 && __lhs.value() < __rhs.value()));
215 template<
typename _CharT,
typename _Traits>
216 basic_ostream<_CharT, _Traits>&
217 operator<<(basic_ostream<_CharT, _Traits>& __os,
const error_code& __e)
218 {
return (__os << __e.category().name() <<
':' << __e.value()); }
220 error_condition make_error_condition(errc)
noexcept;
226 error_condition() noexcept
227 : _M_value(0), _M_cat(&generic_category()) { }
229 error_condition(
int __v,
const error_category& __cat) noexcept
230 : _M_value(__v), _M_cat(&__cat) { }
232 template<
typename _ErrorConditionEnum,
typename =
typename
234 error_condition(_ErrorConditionEnum __e) noexcept
235 { *
this = make_error_condition(__e); }
238 assign(
int __v,
const error_category& __cat) noexcept
245 template<
typename _ErrorConditionEnum>
247 <_ErrorConditionEnum>::value, error_condition&>::type
248 operator=(_ErrorConditionEnum __e) noexcept
249 {
return *
this = make_error_condition(__e); }
253 { assign(0, generic_category()); }
257 value()
const noexcept {
return _M_value; }
259 const error_category&
260 category()
const noexcept {
return *_M_cat; }
262 _GLIBCXX_DEFAULT_ABI_TAG
265 {
return category().message(value()); }
267 explicit operator bool()
const noexcept
268 {
return _M_value != 0; }
273 const error_category* _M_cat;
278 make_error_condition(errc __e)
noexcept
282 operator<(
const error_condition& __lhs,
283 const error_condition& __rhs)
noexcept
285 return (__lhs.category() < __rhs.category()
286 || (__lhs.category() == __rhs.category()
287 && __lhs.value() < __rhs.value()));
292 operator==(
const error_code& __lhs,
const error_code& __rhs)
noexcept
293 {
return (__lhs.category() == __rhs.category()
294 && __lhs.value() == __rhs.value()); }
297 operator==(
const error_code& __lhs,
const error_condition& __rhs)
noexcept
299 return (__lhs.category().equivalent(__lhs.value(), __rhs)
300 || __rhs.category().equivalent(__lhs, __rhs.value()));
304 operator==(
const error_condition& __lhs,
const error_code& __rhs)
noexcept
306 return (__rhs.category().equivalent(__rhs.value(), __lhs)
307 || __lhs.category().equivalent(__rhs, __lhs.value()));
311 operator==(
const error_condition& __lhs,
312 const error_condition& __rhs)
noexcept
314 return (__lhs.category() == __rhs.category()
315 && __lhs.value() == __rhs.value());
319 operator!=(
const error_code& __lhs,
const error_code& __rhs)
noexcept
320 {
return !(__lhs == __rhs); }
323 operator!=(
const error_code& __lhs,
const error_condition& __rhs)
noexcept
324 {
return !(__lhs == __rhs); }
327 operator!=(
const error_condition& __lhs,
const error_code& __rhs)
noexcept
328 {
return !(__lhs == __rhs); }
331 operator!=(
const error_condition& __lhs,
332 const error_condition& __rhs)
noexcept
333 {
return !(__lhs == __rhs); }
351 :
runtime_error(__what +
": " + __ec.message()), _M_code(__ec) { }
354 :
runtime_error(__what + (
": " + __ec.message())), _M_code(__ec) { }
356 system_error(
int __v,
const error_category& __ecat,
const char* __what)
361 _M_code(__v, __ecat) { }
363 system_error(
int __v,
const error_category& __ecat,
const string& __what)
365 _M_code(__v, __ecat) { }
367 #if __cplusplus >= 201103L
375 code()
const noexcept {
return _M_code; }
378 _GLIBCXX_END_NAMESPACE_VERSION
383 namespace std _GLIBCXX_VISIBILITY(default)
385 _GLIBCXX_BEGIN_NAMESPACE_VERSION
387 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X
392 :
public __hash_base<size_t, error_code>
397 const size_t __tmp = std::_Hash_impl::hash(__e._M_value);
398 return std::_Hash_impl::__hash_combine(__e._M_cat, __tmp);
401 #endif // _GLIBCXX_COMPATIBILITY_CXX0X
403 #if __cplusplus > 201402L
408 :
public __hash_base<size_t, error_condition>
413 const size_t __tmp = std::_Hash_impl::hash(__e.value());
414 return std::_Hash_impl::__hash_combine(__e.category(), __tmp);
419 _GLIBCXX_END_NAMESPACE_VERSION
424 #endif // _GLIBCXX_SYSTEM_ERROR
One of two subclasses of exception.
enable_if< ::__array_traits< _Tp, _Nm >::_Is_swappable::value >::type noexcept(noexcept(__one.swap(__two)))
swap
Define a member typedef type only if a boolean constant is true.
Thrown to indicate error code of underlying system.
One of the comparison functors.
Primary class template hash.