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>
66 template <
typename _Tp>
67 constexpr
bool is_error_condition_enum_v =
70 inline namespace _V2 {
84 name()
const noexcept = 0;
90 #if _GLIBCXX_USE_CXX11_ABI 92 _GLIBCXX_DEFAULT_ABI_TAG
94 _M_message(
int)
const;
97 _GLIBCXX_DEFAULT_ABI_TAG
99 message(
int)
const = 0;
102 message(
int)
const = 0;
106 _M_message(
int)
const;
111 default_error_condition(
int __i)
const noexcept;
117 equivalent(
const error_code& __code,
int __i)
const noexcept;
125 {
return this == &__other; }
129 {
return this != &__other; }
140 template<
typename _Tp>
148 : _M_value(0), _M_cat(&system_category()) { }
150 error_code(
int __v,
const error_category& __cat) noexcept
151 : _M_value(__v), _M_cat(&__cat) { }
153 template<
typename _ErrorCodeEnum,
typename =
typename 154 enable_if<is_error_code_enum<_ErrorCodeEnum>::value>::type>
156 { *
this = make_error_code(__e); }
159 assign(
int __v,
const error_category& __cat) noexcept
167 { assign(0, system_category()); }
170 template<
typename _ErrorCodeEnum>
171 typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value,
173 operator=(_ErrorCodeEnum __e) noexcept
174 {
return *
this = make_error_code(__e); }
177 value()
const noexcept {
return _M_value; }
179 const error_category&
180 category()
const noexcept {
return *_M_cat; }
183 default_error_condition()
const noexcept;
185 _GLIBCXX_DEFAULT_ABI_TAG
188 {
return category().message(value()); }
190 explicit operator bool()
const noexcept
191 {
return _M_value != 0; }
195 friend class hash<error_code>;
198 const error_category* _M_cat;
203 make_error_code(errc __e) noexcept
204 {
return error_code(static_cast<int>(__e), generic_category()); }
209 return (__lhs.category() < __rhs.category()
210 || (__lhs.category() == __rhs.category()
211 && __lhs.value() < __rhs.value()));
214 template<
typename _CharT,
typename _Traits>
216 operator<<(basic_ostream<_CharT, _Traits>& __os,
const error_code& __e)
217 {
return (__os << __e.category().name() <<
':' << __e.value()); }
226 : _M_value(0), _M_cat(&generic_category()) { }
229 : _M_value(__v), _M_cat(&__cat) { }
231 template<
typename _ErrorConditionEnum,
typename =
typename 232 enable_if<is_error_condition_enum<_ErrorConditionEnum>::value>::type>
234 { *
this = make_error_condition(__e); }
237 assign(
int __v,
const error_category& __cat) noexcept
244 template<
typename _ErrorConditionEnum>
247 operator=(_ErrorConditionEnum __e) noexcept
248 {
return *
this = make_error_condition(__e); }
252 { assign(0, generic_category()); }
256 value()
const noexcept {
return _M_value; }
258 const error_category&
259 category()
const noexcept {
return *_M_cat; }
261 _GLIBCXX_DEFAULT_ABI_TAG
264 {
return category().message(value()); }
266 explicit operator bool()
const noexcept
267 {
return _M_value != 0; }
272 const error_category* _M_cat;
277 make_error_condition(errc __e) noexcept
284 return (__lhs.category() < __rhs.category()
285 || (__lhs.category() == __rhs.category()
286 && __lhs.value() < __rhs.value()));
292 {
return (__lhs.category() == __rhs.category()
293 && __lhs.value() == __rhs.value()); }
298 return (__lhs.category().equivalent(__lhs.value(), __rhs)
299 || __rhs.category().equivalent(__lhs, __rhs.value()));
305 return (__rhs.category().equivalent(__rhs.value(), __lhs)
306 || __lhs.category().equivalent(__rhs, __lhs.value()));
313 return (__lhs.category() == __rhs.category()
314 && __lhs.value() == __rhs.value());
319 {
return !(__lhs == __rhs); }
323 {
return !(__lhs == __rhs); }
327 {
return !(__lhs == __rhs); }
332 {
return !(__lhs == __rhs); }
350 :
runtime_error(__what +
": " + __ec.message()), _M_code(__ec) { }
353 :
runtime_error(__what + (
": " + __ec.message())), _M_code(__ec) { }
355 system_error(
int __v,
const error_category& __ecat,
const char* __what)
360 _M_code(__v, __ecat) { }
362 system_error(
int __v,
const error_category& __ecat,
const string& __what)
364 _M_code(__v, __ecat) { }
369 code()
const noexcept {
return _M_code; }
372 _GLIBCXX_END_NAMESPACE_VERSION
375 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X 379 namespace std _GLIBCXX_VISIBILITY(default)
381 _GLIBCXX_BEGIN_NAMESPACE_VERSION
387 :
public __hash_base<size_t, error_code>
390 operator()(
const error_code& __e)
const noexcept
392 const size_t __tmp = std::_Hash_impl::hash(__e._M_value);
393 return std::_Hash_impl::__hash_combine(__e._M_cat, __tmp);
397 _GLIBCXX_END_NAMESPACE_VERSION
400 #endif // _GLIBCXX_COMPATIBILITY_CXX0X 404 #endif // _GLIBCXX_SYSTEM_ERROR
Template class basic_ostream.
One of two subclasses of exception.
Thrown to indicate error code of underlying system.
ISO C++ entities toplevel namespace is std.
One of the comparison functors.
Primary class template hash.