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>
78 name()
const noexcept = 0;
81 message(
int)
const = 0;
84 default_error_condition(
int __i)
const noexcept;
90 equivalent(
const error_code& __code,
int __i)
const noexcept;
98 {
return this == &__other; }
102 {
return this != &__other; }
111 template<typename _Tp>
118 error_code() noexcept
119 : _M_value(0), _M_cat(&system_category()) { }
122 : _M_value(__v), _M_cat(&__cat) { }
124 template<
typename _ErrorCodeEnum,
typename =
typename
126 error_code(_ErrorCodeEnum __e) noexcept
127 { *
this = make_error_code(__e); }
138 { assign(0, system_category()); }
141 template<
typename _ErrorCodeEnum>
144 operator=(_ErrorCodeEnum __e) noexcept
145 {
return *
this = make_error_code(__e); }
148 value()
const noexcept {
return _M_value; }
151 category()
const noexcept {
return *_M_cat; }
154 default_error_condition()
const noexcept;
158 {
return category().message(value()); }
160 explicit operator bool()
const noexcept
161 {
return _M_value != 0 ?
true :
false; }
165 friend class hash<error_code>;
173 make_error_code(errc __e) noexcept
174 {
return error_code(static_cast<int>(__e), generic_category()); }
177 operator<(
const error_code& __lhs,
const error_code& __rhs) noexcept
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) noexcept;
195 error_condition() noexcept
196 : _M_value(0), _M_cat(&generic_category()) { }
199 : _M_value(__v), _M_cat(&__cat) { }
201 template<
typename _ErrorConditionEnum,
typename =
typename
203 error_condition(_ErrorConditionEnum __e) noexcept
204 { *
this = make_error_condition(__e); }
214 template<
typename _ErrorConditionEnum>
216 <_ErrorConditionEnum>::value, error_condition&>::type
217 operator=(_ErrorConditionEnum __e) noexcept
218 {
return *
this = make_error_condition(__e); }
222 { assign(0, generic_category()); }
226 value()
const noexcept {
return _M_value; }
229 category()
const noexcept {
return *_M_cat; }
233 {
return category().message(value()); }
235 explicit operator bool()
const noexcept
236 {
return _M_value != 0 ?
true :
false; }
246 make_error_condition(errc __e) noexcept
250 operator<(
const error_condition& __lhs,
251 const error_condition& __rhs) noexcept
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) noexcept
261 {
return (__lhs.category() == __rhs.category()
262 && __lhs.value() == __rhs.value()); }
265 operator==(
const error_code& __lhs,
const error_condition& __rhs) noexcept
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) noexcept
274 return (__rhs.category().equivalent(__rhs.value(), __lhs)
275 || __lhs.category().equivalent(__rhs, __lhs.value()));
279 operator==(
const error_condition& __lhs,
280 const error_condition& __rhs) noexcept
282 return (__lhs.category() == __rhs.category()
283 && __lhs.value() == __rhs.value());
287 operator!=(
const error_code& __lhs,
const error_code& __rhs) noexcept
288 {
return !(__lhs == __rhs); }
291 operator!=(
const error_code& __lhs,
const error_condition& __rhs) noexcept
292 {
return !(__lhs == __rhs); }
295 operator!=(
const error_condition& __lhs,
const error_code& __rhs) noexcept
296 {
return !(__lhs == __rhs); }
299 operator!=(
const error_condition& __lhs,
300 const error_condition& __rhs) noexcept
301 {
return !(__lhs == __rhs); }
319 :
runtime_error(__what +
": " + __ec.message()), _M_code(__ec) { }
334 _M_code(__v, __ecat) { }
338 _M_code(__v, __ecat) { }
343 code()
const noexcept {
return _M_code; }
346 _GLIBCXX_END_NAMESPACE_VERSION
349 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X
353 namespace std _GLIBCXX_VISIBILITY(default)
355 _GLIBCXX_BEGIN_NAMESPACE_VERSION
361 :
public __hash_base<size_t, error_code>
364 operator()(
const error_code& __e)
const noexcept
366 const size_t __tmp = std::_Hash_impl::hash(__e._M_value);
367 return std::_Hash_impl::__hash_combine(__e._M_cat, __tmp);
371 _GLIBCXX_END_NAMESPACE_VERSION
374 #endif // _GLIBCXX_COMPATIBILITY_CXX0X
376 #endif // __GXX_EXPERIMENTAL_CXX0X__
378 #endif // _GLIBCXX_SYSTEM_ERROR
Define a member typedef type only if a boolean constant is true.
One of two subclasses of exception.
One of the comparison functors.
runtime_error(const string &__arg)
Thrown to indicate error code of underlying system.
Primary class template hash.