29 #ifndef _GLIBCXX_SYSTEM_ERROR
30 #define _GLIBCXX_SYSTEM_ERROR 1
32 #pragma GCC system_header
34 #ifndef __GXX_EXPERIMENTAL_CXX0X__
43 namespace std _GLIBCXX_VISIBILITY(default)
45 _GLIBCXX_BEGIN_NAMESPACE_VERSION
48 class error_condition;
53 template<
typename _Tp>
57 template<
typename _Tp>
81 message(
int)
const = 0;
84 default_error_condition(
int __i)
const;
90 equivalent(
const error_code& __code,
int __i)
const;
98 {
return this == &__other; }
102 {
return this != &__other; }
111 template<typename _Tp>
119 : _M_value(0), _M_cat(&system_category()) { }
122 : _M_value(__v), _M_cat(&__cat) { }
124 template<
typename _ErrorCodeEnum>
125 error_code(_ErrorCodeEnum __e,
127 { *
this = make_error_code(__e); }
138 { assign(0, system_category()); }
141 template<
typename _ErrorCodeEnum>
144 operator=(_ErrorCodeEnum __e)
145 {
return *
this = make_error_code(__e); }
148 value()
const {
return _M_value; }
151 category()
const {
return *_M_cat; }
154 default_error_condition()
const;
158 {
return category().message(value()); }
160 explicit operator bool()
const
161 {
return _M_value != 0 ?
true :
false; }
165 friend class hash<error_code>;
173 make_error_code(errc __e)
174 {
return error_code(static_cast<int>(__e), generic_category()); }
177 operator<(
const error_code& __lhs,
const error_code& __rhs)
179 return (__lhs.category() < __rhs.category()
180 || (__lhs.category() == __rhs.category()
181 && __lhs.value() < __rhs.value()));
184 template<
typename _CharT,
typename _Traits>
185 basic_ostream<_CharT, _Traits>&
186 operator<<(basic_ostream<_CharT, _Traits>& __os,
const error_code& __e)
187 {
return (__os << __e.category().name() <<
':' << __e.value()); }
189 error_condition make_error_condition(errc);
196 : _M_value(0), _M_cat(&generic_category()) { }
199 : _M_value(__v), _M_cat(&__cat) { }
201 template<
typename _ErrorConditionEnum>
204 <_ErrorConditionEnum>::value>::type* = 0)
205 { *
this = make_error_condition(__e); }
215 template<
typename _ErrorConditionEnum>
218 operator=(_ErrorConditionEnum __e)
219 {
return *
this = make_error_condition(__e); }
223 { assign(0, generic_category()); }
227 value()
const {
return _M_value; }
230 category()
const {
return *_M_cat; }
234 {
return category().message(value()); }
236 explicit operator bool()
const
237 {
return _M_value != 0 ?
true :
false; }
247 make_error_condition(errc __e)
251 operator<(
const error_condition& __lhs,
const error_condition& __rhs)
253 return (__lhs.category() < __rhs.category()
254 || (__lhs.category() == __rhs.category()
255 && __lhs.value() < __rhs.value()));
260 operator==(
const error_code& __lhs,
const error_code& __rhs)
261 {
return (__lhs.category() == __rhs.category()
262 && __lhs.value() == __rhs.value()); }
265 operator==(
const error_code& __lhs,
const error_condition& __rhs)
267 return (__lhs.category().equivalent(__lhs.value(), __rhs)
268 || __rhs.category().equivalent(__lhs, __rhs.value()));
272 operator==(
const error_condition& __lhs,
const error_code& __rhs)
274 return (__rhs.category().equivalent(__rhs.value(), __lhs)
275 || __lhs.category().equivalent(__rhs, __lhs.value()));
279 operator==(
const error_condition& __lhs,
const error_condition& __rhs)
281 return (__lhs.category() == __rhs.category()
282 && __lhs.value() == __rhs.value());
286 operator!=(
const error_code& __lhs,
const error_code& __rhs)
287 {
return !(__lhs == __rhs); }
290 operator!=(
const error_code& __lhs,
const error_condition& __rhs)
291 {
return !(__lhs == __rhs); }
294 operator!=(
const error_condition& __lhs,
const error_code& __rhs)
295 {
return !(__lhs == __rhs); }
298 operator!=(
const error_condition& __lhs,
const error_condition& __rhs)
299 {
return !(__lhs == __rhs); }
317 :
runtime_error(__what +
": " + __ec.message()), _M_code(__ec) { }
332 _M_code(__v, __ecat) { }
336 _M_code(__v, __ecat) { }
341 code()
const throw() {
return _M_code; }
344 _GLIBCXX_END_NAMESPACE_VERSION
347 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X
351 namespace std _GLIBCXX_VISIBILITY(default)
353 _GLIBCXX_BEGIN_NAMESPACE_VERSION
359 :
public __hash_base<size_t, error_code>
364 const size_t __tmp = std::_Hash_impl::hash(__e._M_value);
365 return std::_Hash_impl::__hash_combine(__e._M_cat, __tmp);
369 _GLIBCXX_END_NAMESPACE_VERSION
372 #endif // _GLIBCXX_COMPATIBILITY_CXX0X
374 #endif // __GXX_EXPERIMENTAL_CXX0X__
376 #endif // _GLIBCXX_SYSTEM_ERROR
Primary class template hash.
One of two subclasses of exception.
runtime_error(const string &__arg)
One of the comparison functors.
Thrown to indicate error code of underlying system.