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 inline namespace _V2 {
77 name()
const noexcept = 0;
83 #if _GLIBCXX_USE_CXX11_ABI
85 _GLIBCXX_DEFAULT_ABI_TAG
87 _M_message(
int)
const;
90 _GLIBCXX_DEFAULT_ABI_TAG
92 message(
int)
const = 0;
95 message(
int)
const = 0;
99 _M_message(
int)
const;
104 default_error_condition(
int __i)
const noexcept;
110 equivalent(
const error_code& __code,
int __i)
const noexcept;
118 {
return this == &__other; }
122 {
return this != &__other; }
133 template<typename _Tp>
140 error_code() noexcept
141 : _M_value(0), _M_cat(&system_category()) { }
143 error_code(
int __v,
const error_category& __cat) noexcept
144 : _M_value(__v), _M_cat(&__cat) { }
146 template<
typename _ErrorCodeEnum,
typename =
typename
147 enable_if<is_error_code_enum<_ErrorCodeEnum>::value>::type>
148 error_code(_ErrorCodeEnum __e) noexcept
149 { *
this = make_error_code(__e); }
152 assign(
int __v,
const error_category& __cat) noexcept
160 { assign(0, system_category()); }
163 template<
typename _ErrorCodeEnum>
164 typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value,
166 operator=(_ErrorCodeEnum __e) noexcept
167 {
return *
this = make_error_code(__e); }
170 value()
const noexcept {
return _M_value; }
172 const error_category&
173 category()
const noexcept {
return *_M_cat; }
176 default_error_condition()
const noexcept;
178 _GLIBCXX_DEFAULT_ABI_TAG
181 {
return category().message(value()); }
183 explicit operator bool()
const noexcept
184 {
return _M_value != 0; }
188 friend class hash<error_code>;
191 const error_category* _M_cat;
196 make_error_code(errc __e) noexcept
197 {
return error_code(static_cast<int>(__e), generic_category()); }
200 operator<(
const error_code& __lhs,
const error_code& __rhs) noexcept
202 return (__lhs.category() < __rhs.category()
203 || (__lhs.category() == __rhs.category()
204 && __lhs.value() < __rhs.value()));
207 template<
typename _CharT,
typename _Traits>
208 basic_ostream<_CharT, _Traits>&
209 operator<<(basic_ostream<_CharT, _Traits>& __os,
const error_code& __e)
210 {
return (__os << __e.category().name() <<
':' << __e.value()); }
212 error_condition make_error_condition(errc) noexcept;
218 error_condition() noexcept
219 : _M_value(0), _M_cat(&generic_category()) { }
221 error_condition(
int __v,
const error_category& __cat) noexcept
222 : _M_value(__v), _M_cat(&__cat) { }
224 template<
typename _ErrorConditionEnum,
typename =
typename
225 enable_if<is_error_condition_enum<_ErrorConditionEnum>::value>::type>
226 error_condition(_ErrorConditionEnum __e) noexcept
227 { *
this = make_error_condition(__e); }
230 assign(
int __v,
const error_category& __cat) noexcept
237 template<
typename _ErrorConditionEnum>
239 <_ErrorConditionEnum>::value, error_condition&>::type
240 operator=(_ErrorConditionEnum __e) noexcept
241 {
return *
this = make_error_condition(__e); }
245 { assign(0, generic_category()); }
249 value()
const noexcept {
return _M_value; }
251 const error_category&
252 category()
const noexcept {
return *_M_cat; }
254 _GLIBCXX_DEFAULT_ABI_TAG
257 {
return category().message(value()); }
259 explicit operator bool()
const noexcept
260 {
return _M_value != 0; }
265 const error_category* _M_cat;
270 make_error_condition(errc __e) noexcept
274 operator<(
const error_condition& __lhs,
275 const error_condition& __rhs) noexcept
277 return (__lhs.category() < __rhs.category()
278 || (__lhs.category() == __rhs.category()
279 && __lhs.value() < __rhs.value()));
284 operator==(
const error_code& __lhs,
const error_code& __rhs) noexcept
285 {
return (__lhs.category() == __rhs.category()
286 && __lhs.value() == __rhs.value()); }
289 operator==(
const error_code& __lhs,
const error_condition& __rhs) noexcept
291 return (__lhs.category().equivalent(__lhs.value(), __rhs)
292 || __rhs.category().equivalent(__lhs, __rhs.value()));
296 operator==(
const error_condition& __lhs,
const error_code& __rhs) noexcept
298 return (__rhs.category().equivalent(__rhs.value(), __lhs)
299 || __lhs.category().equivalent(__rhs, __lhs.value()));
303 operator==(
const error_condition& __lhs,
304 const error_condition& __rhs) noexcept
306 return (__lhs.category() == __rhs.category()
307 && __lhs.value() == __rhs.value());
311 operator!=(
const error_code& __lhs,
const error_code& __rhs) noexcept
312 {
return !(__lhs == __rhs); }
315 operator!=(
const error_code& __lhs,
const error_condition& __rhs) noexcept
316 {
return !(__lhs == __rhs); }
319 operator!=(
const error_condition& __lhs,
const error_code& __rhs) noexcept
320 {
return !(__lhs == __rhs); }
323 operator!=(
const error_condition& __lhs,
324 const error_condition& __rhs) noexcept
325 {
return !(__lhs == __rhs); }
343 :
runtime_error(__what +
": " + __ec.message()), _M_code(__ec) { }
346 :
runtime_error(__what + (
": " + __ec.message())), _M_code(__ec) { }
348 system_error(
int __v,
const error_category& __ecat,
const char* __what)
353 _M_code(__v, __ecat) { }
355 system_error(
int __v,
const error_category& __ecat,
const string& __what)
357 _M_code(__v, __ecat) { }
362 code()
const noexcept {
return _M_code; }
365 _GLIBCXX_END_NAMESPACE_VERSION
368 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X
372 namespace std _GLIBCXX_VISIBILITY(default)
374 _GLIBCXX_BEGIN_NAMESPACE_VERSION
380 :
public __hash_base<size_t, error_code>
383 operator()(
const error_code& __e)
const noexcept
385 const size_t __tmp = std::_Hash_impl::hash(__e._M_value);
386 return std::_Hash_impl::__hash_combine(__e._M_cat, __tmp);
390 _GLIBCXX_END_NAMESPACE_VERSION
393 #endif // _GLIBCXX_COMPATIBILITY_CXX0X
397 #endif // _GLIBCXX_SYSTEM_ERROR
Primary class template hash.
Thrown to indicate error code of underlying system.
One of two subclasses of exception.
One of the comparison functors.