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;
53 template<
typename _Tp>
57 template<
typename _Tp>
69 #ifdef _GLIBCXX_COMPATIBILITY_CXX0X
81 name()
const noexcept = 0;
84 message(
int)
const = 0;
87 default_error_condition(
int __i)
const noexcept;
93 equivalent(
const error_code& __code,
int __i)
const noexcept;
101 {
return this == &__other; }
105 {
return this != &__other; }
114 template<typename _Tp>
121 error_code() noexcept
122 : _M_value(0), _M_cat(&system_category()) { }
125 : _M_value(__v), _M_cat(&__cat) { }
127 template<
typename _ErrorCodeEnum,
typename =
typename
128 enable_if<is_error_code_enum<_ErrorCodeEnum>::value>::type>
129 error_code(_ErrorCodeEnum __e) noexcept
130 { *
this = make_error_code(__e); }
141 { assign(0, system_category()); }
144 template<
typename _ErrorCodeEnum>
145 typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value,
147 operator=(_ErrorCodeEnum __e) noexcept
148 {
return *
this = make_error_code(__e); }
151 value()
const noexcept {
return _M_value; }
154 category()
const noexcept {
return *_M_cat; }
157 default_error_condition()
const noexcept;
161 {
return category().message(value()); }
163 explicit operator bool()
const noexcept
164 {
return _M_value != 0 ?
true :
false; }
168 friend class hash<error_code>;
176 make_error_code(errc __e) noexcept
177 {
return error_code(static_cast<int>(__e), generic_category()); }
180 operator<(
const error_code& __lhs,
const error_code& __rhs) noexcept
182 return (__lhs.category() < __rhs.category()
183 || (__lhs.category() == __rhs.category()
184 && __lhs.value() < __rhs.value()));
187 template<
typename _CharT,
typename _Traits>
188 basic_ostream<_CharT, _Traits>&
189 operator<<(basic_ostream<_CharT, _Traits>& __os,
const error_code& __e)
190 {
return (__os << __e.category().name() <<
':' << __e.value()); }
192 error_condition make_error_condition(errc) noexcept;
198 error_condition() noexcept
199 : _M_value(0), _M_cat(&generic_category()) { }
202 : _M_value(__v), _M_cat(&__cat) { }
204 template<
typename _ErrorConditionEnum,
typename =
typename
205 enable_if<is_error_condition_enum<_ErrorConditionEnum>::value>::type>
206 error_condition(_ErrorConditionEnum __e) noexcept
207 { *
this = make_error_condition(__e); }
217 template<
typename _ErrorConditionEnum>
219 <_ErrorConditionEnum>::value, error_condition&>::type
220 operator=(_ErrorConditionEnum __e) noexcept
221 {
return *
this = make_error_condition(__e); }
225 { assign(0, generic_category()); }
229 value()
const noexcept {
return _M_value; }
232 category()
const noexcept {
return *_M_cat; }
236 {
return category().message(value()); }
238 explicit operator bool()
const noexcept
239 {
return _M_value != 0 ?
true :
false; }
249 make_error_condition(errc __e) noexcept
253 operator<(
const error_condition& __lhs,
254 const error_condition& __rhs) noexcept
256 return (__lhs.category() < __rhs.category()
257 || (__lhs.category() == __rhs.category()
258 && __lhs.value() < __rhs.value()));
263 operator==(
const error_code& __lhs,
const error_code& __rhs) noexcept
264 {
return (__lhs.category() == __rhs.category()
265 && __lhs.value() == __rhs.value()); }
268 operator==(
const error_code& __lhs,
const error_condition& __rhs) noexcept
270 return (__lhs.category().equivalent(__lhs.value(), __rhs)
271 || __rhs.category().equivalent(__lhs, __rhs.value()));
275 operator==(
const error_condition& __lhs,
const error_code& __rhs) noexcept
277 return (__rhs.category().equivalent(__rhs.value(), __lhs)
278 || __lhs.category().equivalent(__rhs, __lhs.value()));
282 operator==(
const error_condition& __lhs,
283 const error_condition& __rhs) noexcept
285 return (__lhs.category() == __rhs.category()
286 && __lhs.value() == __rhs.value());
290 operator!=(
const error_code& __lhs,
const error_code& __rhs) noexcept
291 {
return !(__lhs == __rhs); }
294 operator!=(
const error_code& __lhs,
const error_condition& __rhs) noexcept
295 {
return !(__lhs == __rhs); }
298 operator!=(
const error_condition& __lhs,
const error_code& __rhs) noexcept
299 {
return !(__lhs == __rhs); }
302 operator!=(
const error_condition& __lhs,
303 const error_condition& __rhs) noexcept
304 {
return !(__lhs == __rhs); }
322 :
runtime_error(__what +
": " + __ec.message()), _M_code(__ec) { }
337 _M_code(__v, __ecat) { }
341 _M_code(__v, __ecat) { }
346 code()
const noexcept {
return _M_code; }
349 _GLIBCXX_END_NAMESPACE_VERSION
352 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X
356 namespace std _GLIBCXX_VISIBILITY(default)
358 _GLIBCXX_BEGIN_NAMESPACE_VERSION
364 :
public __hash_base<size_t, error_code>
367 operator()(
const error_code& __e)
const noexcept
369 const size_t __tmp = std::_Hash_impl::hash(__e._M_value);
370 return std::_Hash_impl::__hash_combine(__e._M_cat, __tmp);
374 _GLIBCXX_END_NAMESPACE_VERSION
377 #endif // _GLIBCXX_COMPATIBILITY_CXX0X
381 #endif // _GLIBCXX_SYSTEM_ERROR
Thrown to indicate error code of underlying system.
One of the comparison functors.
One of two subclasses of exception.
Primary class template hash.
runtime_error(const string &__arg)