Mercurial > hg > CbC > CbC_llvm
comparison libcxx/include/system_error @ 236:c4bab56944e8 llvm-original
LLVM 16
author | kono |
---|---|
date | Wed, 09 Nov 2022 17:45:10 +0900 |
parents | 5f17cb93ff66 |
children | 1f2b6ac9f198 |
comparison
equal
deleted
inserted
replaced
232:70dce7da266c | 236:c4bab56944e8 |
---|---|
1 // -*- C++ -*- | 1 // -*- C++ -*- |
2 //===---------------------------- system_error ----------------------------===// | 2 //===----------------------------------------------------------------------===// |
3 // | 3 // |
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | 4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
5 // See https://llvm.org/LICENSE.txt for license information. | 5 // See https://llvm.org/LICENSE.txt for license information. |
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | 6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
7 // | 7 // |
30 virtual bool equivalent(int code, const error_condition& condition) const noexcept; | 30 virtual bool equivalent(int code, const error_condition& condition) const noexcept; |
31 virtual bool equivalent(const error_code& code, int condition) const noexcept; | 31 virtual bool equivalent(const error_code& code, int condition) const noexcept; |
32 virtual string message(int ev) const = 0; | 32 virtual string message(int ev) const = 0; |
33 | 33 |
34 bool operator==(const error_category& rhs) const noexcept; | 34 bool operator==(const error_category& rhs) const noexcept; |
35 bool operator!=(const error_category& rhs) const noexcept; | 35 bool operator!=(const error_category& rhs) const noexcept; // removed in C++20 |
36 bool operator<(const error_category& rhs) const noexcept; | 36 bool operator<(const error_category& rhs) const noexcept; // removed in C++20 |
37 strong_ordering operator<=>(const error_category& rhs) const noexcept; // C++20 | |
37 }; | 38 }; |
38 | 39 |
39 const error_category& generic_category() noexcept; | 40 const error_category& generic_category() noexcept; |
40 const error_category& system_category() noexcept; | 41 const error_category& system_category() noexcept; |
41 | 42 |
44 | 45 |
45 template <class T> struct is_error_condition_enum | 46 template <class T> struct is_error_condition_enum |
46 : public false_type {}; | 47 : public false_type {}; |
47 | 48 |
48 template <class _Tp> | 49 template <class _Tp> |
49 inline constexpr size_t is_error_condition_enum_v = is_error_condition_enum<_Tp>::value; // C++17 | 50 inline constexpr bool is_error_condition_enum_v = is_error_condition_enum<_Tp>::value; // C++17 |
50 | 51 |
51 template <class _Tp> | 52 template <class _Tp> |
52 inline constexpr size_t is_error_code_enum_v = is_error_code_enum<_Tp>::value; // C++17 | 53 inline constexpr bool is_error_code_enum_v = is_error_code_enum<_Tp>::value; // C++17 |
53 | 54 |
54 class error_code | 55 class error_code |
55 { | 56 { |
56 public: | 57 public: |
57 // constructors: | 58 // constructors: |
73 string message() const; | 74 string message() const; |
74 explicit operator bool() const noexcept; | 75 explicit operator bool() const noexcept; |
75 }; | 76 }; |
76 | 77 |
77 // non-member functions: | 78 // non-member functions: |
78 bool operator<(const error_code& lhs, const error_code& rhs) noexcept; | |
79 template <class charT, class traits> | 79 template <class charT, class traits> |
80 basic_ostream<charT,traits>& | 80 basic_ostream<charT,traits>& |
81 operator<<(basic_ostream<charT,traits>& os, const error_code& ec); | 81 operator<<(basic_ostream<charT,traits>& os, const error_code& ec); |
82 | 82 |
83 class error_condition | 83 class error_condition |
99 int value() const noexcept; | 99 int value() const noexcept; |
100 const error_category& category() const noexcept; | 100 const error_category& category() const noexcept; |
101 string message() const noexcept; | 101 string message() const noexcept; |
102 explicit operator bool() const noexcept; | 102 explicit operator bool() const noexcept; |
103 }; | 103 }; |
104 | |
105 bool operator<(const error_condition& lhs, const error_condition& rhs) noexcept; | |
106 | 104 |
107 class system_error | 105 class system_error |
108 : public runtime_error | 106 : public runtime_error |
109 { | 107 { |
110 public: | 108 public: |
126 error_condition make_error_condition(errc e) noexcept; | 124 error_condition make_error_condition(errc e) noexcept; |
127 | 125 |
128 // Comparison operators: | 126 // Comparison operators: |
129 bool operator==(const error_code& lhs, const error_code& rhs) noexcept; | 127 bool operator==(const error_code& lhs, const error_code& rhs) noexcept; |
130 bool operator==(const error_code& lhs, const error_condition& rhs) noexcept; | 128 bool operator==(const error_code& lhs, const error_condition& rhs) noexcept; |
131 bool operator==(const error_condition& lhs, const error_code& rhs) noexcept; | 129 bool operator==(const error_condition& lhs, const error_code& rhs) noexcept; // removed in C++20 |
132 bool operator==(const error_condition& lhs, const error_condition& rhs) noexcept; | 130 bool operator==(const error_condition& lhs, const error_condition& rhs) noexcept; |
133 bool operator!=(const error_code& lhs, const error_code& rhs) noexcept; | 131 bool operator!=(const error_code& lhs, const error_code& rhs) noexcept; // removed in C++20 |
134 bool operator!=(const error_code& lhs, const error_condition& rhs) noexcept; | 132 bool operator!=(const error_code& lhs, const error_condition& rhs) noexcept; // removed in C++20 |
135 bool operator!=(const error_condition& lhs, const error_code& rhs) noexcept; | 133 bool operator!=(const error_condition& lhs, const error_code& rhs) noexcept; // removed in C++20 |
136 bool operator!=(const error_condition& lhs, const error_condition& rhs) noexcept; | 134 bool operator!=(const error_condition& lhs, const error_condition& rhs) noexcept; // removed in C++20 |
135 bool operator<(const error_condition& lhs, const error_condition& rhs) noexcept; // removed in C++20 | |
136 bool operator<(const error_code& lhs, const error_code& rhs) noexcept; // removed in C++20 | |
137 strong_ordering operator<=>(const error_code& lhs, const error_code& rhs) noexcept; // C++20 | |
138 strong_ordering operator<=>(const error_condition& lhs, const error_condition& rhs) noexcept; // C++20 | |
137 | 139 |
138 template <> struct hash<std::error_code>; | 140 template <> struct hash<std::error_code>; |
139 template <> struct hash<std::error_condition>; | 141 template <> struct hash<std::error_condition>; |
140 | 142 |
141 } // std | 143 } // std |
142 | 144 |
143 */ | 145 */ |
144 | 146 |
147 #include <__assert> // all public C++ headers provide the assertion handler | |
145 #include <__config> | 148 #include <__config> |
146 #include <__errc> | 149 #include <__errc> |
150 #include <__functional/hash.h> | |
147 #include <__functional/unary_function.h> | 151 #include <__functional/unary_function.h> |
148 #include <__functional_base> | 152 #include <__memory/addressof.h> |
149 #include <compare> | |
150 #include <stdexcept> | 153 #include <stdexcept> |
151 #include <string> | 154 #include <string> |
152 #include <type_traits> | 155 #include <type_traits> |
156 #include <version> | |
157 | |
158 // standard-mandated includes | |
159 | |
160 // [system.error.syn] | |
161 #include <compare> | |
153 | 162 |
154 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 163 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
155 #pragma GCC system_header | 164 # pragma GCC system_header |
156 #endif | 165 #endif |
157 | 166 |
158 _LIBCPP_BEGIN_NAMESPACE_STD | 167 _LIBCPP_BEGIN_NAMESPACE_STD |
159 | 168 |
160 // is_error_code_enum | 169 // is_error_code_enum |
163 struct _LIBCPP_TEMPLATE_VIS is_error_code_enum | 172 struct _LIBCPP_TEMPLATE_VIS is_error_code_enum |
164 : public false_type {}; | 173 : public false_type {}; |
165 | 174 |
166 #if _LIBCPP_STD_VER > 14 | 175 #if _LIBCPP_STD_VER > 14 |
167 template <class _Tp> | 176 template <class _Tp> |
168 _LIBCPP_INLINE_VAR constexpr size_t is_error_code_enum_v = is_error_code_enum<_Tp>::value; | 177 inline constexpr bool is_error_code_enum_v = is_error_code_enum<_Tp>::value; |
169 #endif | 178 #endif |
170 | 179 |
171 // is_error_condition_enum | 180 // is_error_condition_enum |
172 | 181 |
173 template <class _Tp> | 182 template <class _Tp> |
174 struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum | 183 struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum |
175 : public false_type {}; | 184 : public false_type {}; |
176 | 185 |
177 #if _LIBCPP_STD_VER > 14 | 186 #if _LIBCPP_STD_VER > 14 |
178 template <class _Tp> | 187 template <class _Tp> |
179 _LIBCPP_INLINE_VAR constexpr size_t is_error_condition_enum_v = is_error_condition_enum<_Tp>::value; | 188 inline constexpr bool is_error_condition_enum_v = is_error_condition_enum<_Tp>::value; |
180 #endif | 189 #endif |
181 | 190 |
182 template <> | 191 template <> |
183 struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum<errc> | 192 struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum<errc> |
184 : true_type { }; | 193 : true_type { }; |
185 | 194 |
186 #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS | 195 #ifdef _LIBCPP_CXX03_LANG |
187 template <> | 196 template <> |
188 struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum<errc::__lx> | 197 struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum<errc::__lx> |
189 : true_type { }; | 198 : true_type { }; |
190 #endif | 199 #endif |
191 | 200 |
199 class _LIBCPP_TYPE_VIS error_category | 208 class _LIBCPP_TYPE_VIS error_category |
200 { | 209 { |
201 public: | 210 public: |
202 virtual ~error_category() _NOEXCEPT; | 211 virtual ~error_category() _NOEXCEPT; |
203 | 212 |
204 #if defined(_LIBCPP_BUILDING_LIBRARY) && \ | 213 #if defined(_LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS) |
205 defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS) | 214 error_category() noexcept; |
206 error_category() _NOEXCEPT; | |
207 #else | 215 #else |
208 _LIBCPP_INLINE_VISIBILITY | 216 _LIBCPP_INLINE_VISIBILITY |
209 _LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT _LIBCPP_DEFAULT | 217 _LIBCPP_CONSTEXPR_SINCE_CXX14 error_category() _NOEXCEPT = default; |
210 #endif | 218 #endif |
211 private: | 219 error_category(const error_category&) = delete; |
212 error_category(const error_category&);// = delete; | 220 error_category& operator=(const error_category&) = delete; |
213 error_category& operator=(const error_category&);// = delete; | 221 |
214 | |
215 public: | |
216 virtual const char* name() const _NOEXCEPT = 0; | 222 virtual const char* name() const _NOEXCEPT = 0; |
217 virtual error_condition default_error_condition(int __ev) const _NOEXCEPT; | 223 virtual error_condition default_error_condition(int __ev) const _NOEXCEPT; |
218 virtual bool equivalent(int __code, const error_condition& __condition) const _NOEXCEPT; | 224 virtual bool equivalent(int __code, const error_condition& __condition) const _NOEXCEPT; |
219 virtual bool equivalent(const error_code& __code, int __condition) const _NOEXCEPT; | 225 virtual bool equivalent(const error_code& __code, int __condition) const _NOEXCEPT; |
220 virtual string message(int __ev) const = 0; | 226 virtual string message(int __ev) const = 0; |
221 | 227 |
222 _LIBCPP_INLINE_VISIBILITY | 228 _LIBCPP_INLINE_VISIBILITY |
223 bool operator==(const error_category& __rhs) const _NOEXCEPT {return this == &__rhs;} | 229 bool operator==(const error_category& __rhs) const _NOEXCEPT {return this == &__rhs;} |
224 | 230 |
231 #if _LIBCPP_STD_VER > 17 | |
232 | |
233 _LIBCPP_HIDE_FROM_ABI | |
234 strong_ordering operator<=>(const error_category& __rhs) const noexcept {return compare_three_way()(this, std::addressof(__rhs));} | |
235 | |
236 #else // _LIBCPP_STD_VER > 17 | |
237 | |
225 _LIBCPP_INLINE_VISIBILITY | 238 _LIBCPP_INLINE_VISIBILITY |
226 bool operator!=(const error_category& __rhs) const _NOEXCEPT {return !(*this == __rhs);} | 239 bool operator!=(const error_category& __rhs) const _NOEXCEPT {return !(*this == __rhs);} |
227 | 240 |
228 _LIBCPP_INLINE_VISIBILITY | 241 _LIBCPP_INLINE_VISIBILITY |
229 bool operator< (const error_category& __rhs) const _NOEXCEPT {return this < &__rhs;} | 242 bool operator< (const error_category& __rhs) const _NOEXCEPT {return this < &__rhs;} |
243 | |
244 #endif // _LIBCPP_STD_VER > 17 | |
230 | 245 |
231 friend class _LIBCPP_HIDDEN __do_message; | 246 friend class _LIBCPP_HIDDEN __do_message; |
232 }; | 247 }; |
233 | 248 |
234 class _LIBCPP_HIDDEN __do_message | 249 class _LIBCPP_HIDDEN __do_message |
235 : public error_category | 250 : public error_category |
236 { | 251 { |
237 public: | 252 public: |
238 virtual string message(int ev) const; | 253 string message(int __ev) const override; |
239 }; | 254 }; |
240 | 255 |
241 _LIBCPP_FUNC_VIS const error_category& generic_category() _NOEXCEPT; | 256 _LIBCPP_FUNC_VIS const error_category& generic_category() _NOEXCEPT; |
242 _LIBCPP_FUNC_VIS const error_category& system_category() _NOEXCEPT; | 257 _LIBCPP_FUNC_VIS const error_category& system_category() _NOEXCEPT; |
258 | |
259 namespace __adl_only { | |
260 // Those cause ADL to trigger but they are not viable candidates, | |
261 // so they are never actually selected. | |
262 void make_error_condition() = delete; | |
263 void make_error_code() = delete; | |
264 } // namespace __adl_only | |
243 | 265 |
244 class _LIBCPP_TYPE_VIS error_condition | 266 class _LIBCPP_TYPE_VIS error_condition |
245 { | 267 { |
246 int __val_; | 268 int __val_; |
247 const error_category* __cat_; | 269 const error_category* __cat_; |
256 template <class _Ep> | 278 template <class _Ep> |
257 _LIBCPP_INLINE_VISIBILITY | 279 _LIBCPP_INLINE_VISIBILITY |
258 error_condition(_Ep __e, | 280 error_condition(_Ep __e, |
259 typename enable_if<is_error_condition_enum<_Ep>::value>::type* = nullptr | 281 typename enable_if<is_error_condition_enum<_Ep>::value>::type* = nullptr |
260 ) _NOEXCEPT | 282 ) _NOEXCEPT |
261 {*this = make_error_condition(__e);} | 283 { |
284 using __adl_only::make_error_condition; | |
285 *this = make_error_condition(__e); | |
286 } | |
262 | 287 |
263 _LIBCPP_INLINE_VISIBILITY | 288 _LIBCPP_INLINE_VISIBILITY |
264 void assign(int __val, const error_category& __cat) _NOEXCEPT | 289 void assign(int __val, const error_category& __cat) _NOEXCEPT |
265 { | 290 { |
266 __val_ = __val; | 291 __val_ = __val; |
273 < | 298 < |
274 is_error_condition_enum<_Ep>::value, | 299 is_error_condition_enum<_Ep>::value, |
275 error_condition& | 300 error_condition& |
276 >::type | 301 >::type |
277 operator=(_Ep __e) _NOEXCEPT | 302 operator=(_Ep __e) _NOEXCEPT |
278 {*this = make_error_condition(__e); return *this;} | 303 { |
304 using __adl_only::make_error_condition; | |
305 *this = make_error_condition(__e); | |
306 return *this; | |
307 } | |
279 | 308 |
280 _LIBCPP_INLINE_VISIBILITY | 309 _LIBCPP_INLINE_VISIBILITY |
281 void clear() _NOEXCEPT | 310 void clear() _NOEXCEPT |
282 { | 311 { |
283 __val_ = 0; | 312 __val_ = 0; |
300 make_error_condition(errc __e) _NOEXCEPT | 329 make_error_condition(errc __e) _NOEXCEPT |
301 { | 330 { |
302 return error_condition(static_cast<int>(__e), generic_category()); | 331 return error_condition(static_cast<int>(__e), generic_category()); |
303 } | 332 } |
304 | 333 |
305 inline _LIBCPP_INLINE_VISIBILITY | |
306 bool | |
307 operator<(const error_condition& __x, const error_condition& __y) _NOEXCEPT | |
308 { | |
309 return __x.category() < __y.category() | |
310 || (__x.category() == __y.category() && __x.value() < __y.value()); | |
311 } | |
312 | |
313 // error_code | 334 // error_code |
314 | 335 |
315 class _LIBCPP_TYPE_VIS error_code | 336 class _LIBCPP_TYPE_VIS error_code |
316 { | 337 { |
317 int __val_; | 338 int __val_; |
327 template <class _Ep> | 348 template <class _Ep> |
328 _LIBCPP_INLINE_VISIBILITY | 349 _LIBCPP_INLINE_VISIBILITY |
329 error_code(_Ep __e, | 350 error_code(_Ep __e, |
330 typename enable_if<is_error_code_enum<_Ep>::value>::type* = nullptr | 351 typename enable_if<is_error_code_enum<_Ep>::value>::type* = nullptr |
331 ) _NOEXCEPT | 352 ) _NOEXCEPT |
332 {*this = make_error_code(__e);} | 353 { |
354 using __adl_only::make_error_code; | |
355 *this = make_error_code(__e); | |
356 } | |
333 | 357 |
334 _LIBCPP_INLINE_VISIBILITY | 358 _LIBCPP_INLINE_VISIBILITY |
335 void assign(int __val, const error_category& __cat) _NOEXCEPT | 359 void assign(int __val, const error_category& __cat) _NOEXCEPT |
336 { | 360 { |
337 __val_ = __val; | 361 __val_ = __val; |
344 < | 368 < |
345 is_error_code_enum<_Ep>::value, | 369 is_error_code_enum<_Ep>::value, |
346 error_code& | 370 error_code& |
347 >::type | 371 >::type |
348 operator=(_Ep __e) _NOEXCEPT | 372 operator=(_Ep __e) _NOEXCEPT |
349 {*this = make_error_code(__e); return *this;} | 373 { |
374 using __adl_only::make_error_code; | |
375 *this = make_error_code(__e); | |
376 return *this; | |
377 } | |
350 | 378 |
351 _LIBCPP_INLINE_VISIBILITY | 379 _LIBCPP_INLINE_VISIBILITY |
352 void clear() _NOEXCEPT | 380 void clear() _NOEXCEPT |
353 { | 381 { |
354 __val_ = 0; | 382 __val_ = 0; |
378 return error_code(static_cast<int>(__e), generic_category()); | 406 return error_code(static_cast<int>(__e), generic_category()); |
379 } | 407 } |
380 | 408 |
381 inline _LIBCPP_INLINE_VISIBILITY | 409 inline _LIBCPP_INLINE_VISIBILITY |
382 bool | 410 bool |
383 operator<(const error_code& __x, const error_code& __y) _NOEXCEPT | 411 operator==(const error_code& __x, const error_code& __y) _NOEXCEPT |
412 { | |
413 return __x.category() == __y.category() && __x.value() == __y.value(); | |
414 } | |
415 | |
416 inline _LIBCPP_INLINE_VISIBILITY | |
417 bool | |
418 operator==(const error_code& __x, const error_condition& __y) _NOEXCEPT | |
419 { | |
420 return __x.category().equivalent(__x.value(), __y) | |
421 || __y.category().equivalent(__x, __y.value()); | |
422 } | |
423 | |
424 #if _LIBCPP_STD_VER <= 17 | |
425 inline _LIBCPP_INLINE_VISIBILITY | |
426 bool | |
427 operator==(const error_condition& __x, const error_code& __y) _NOEXCEPT | |
428 { | |
429 return __y == __x; | |
430 } | |
431 #endif | |
432 | |
433 inline _LIBCPP_INLINE_VISIBILITY | |
434 bool | |
435 operator==(const error_condition& __x, const error_condition& __y) _NOEXCEPT | |
436 { | |
437 return __x.category() == __y.category() && __x.value() == __y.value(); | |
438 } | |
439 | |
440 #if _LIBCPP_STD_VER <= 17 | |
441 | |
442 inline _LIBCPP_INLINE_VISIBILITY | |
443 bool | |
444 operator!=(const error_code& __x, const error_code& __y) _NOEXCEPT | |
445 {return !(__x == __y);} | |
446 | |
447 inline _LIBCPP_INLINE_VISIBILITY | |
448 bool | |
449 operator!=(const error_code& __x, const error_condition& __y) _NOEXCEPT | |
450 {return !(__x == __y);} | |
451 | |
452 inline _LIBCPP_INLINE_VISIBILITY | |
453 bool | |
454 operator!=(const error_condition& __x, const error_code& __y) _NOEXCEPT | |
455 {return !(__x == __y);} | |
456 | |
457 inline _LIBCPP_INLINE_VISIBILITY | |
458 bool | |
459 operator!=(const error_condition& __x, const error_condition& __y) _NOEXCEPT | |
460 {return !(__x == __y);} | |
461 | |
462 inline _LIBCPP_INLINE_VISIBILITY | |
463 bool | |
464 operator<(const error_condition& __x, const error_condition& __y) _NOEXCEPT | |
384 { | 465 { |
385 return __x.category() < __y.category() | 466 return __x.category() < __y.category() |
386 || (__x.category() == __y.category() && __x.value() < __y.value()); | 467 || (__x.category() == __y.category() && __x.value() < __y.value()); |
387 } | 468 } |
388 | 469 |
389 inline _LIBCPP_INLINE_VISIBILITY | 470 inline _LIBCPP_INLINE_VISIBILITY |
390 bool | 471 bool |
391 operator==(const error_code& __x, const error_code& __y) _NOEXCEPT | 472 operator<(const error_code& __x, const error_code& __y) _NOEXCEPT |
392 { | 473 { |
393 return __x.category() == __y.category() && __x.value() == __y.value(); | 474 return __x.category() < __y.category() |
394 } | 475 || (__x.category() == __y.category() && __x.value() < __y.value()); |
395 | 476 } |
396 inline _LIBCPP_INLINE_VISIBILITY | 477 |
397 bool | 478 #else // _LIBCPP_STD_VER <= 17 |
398 operator==(const error_code& __x, const error_condition& __y) _NOEXCEPT | 479 |
399 { | 480 inline _LIBCPP_HIDE_FROM_ABI strong_ordering |
400 return __x.category().equivalent(__x.value(), __y) | 481 operator<=>(const error_code& __x, const error_code& __y) noexcept |
401 || __y.category().equivalent(__x, __y.value()); | 482 { |
402 } | 483 if (auto __c = __x.category() <=> __y.category(); __c != 0) |
403 | 484 return __c; |
404 inline _LIBCPP_INLINE_VISIBILITY | 485 return __x.value() <=> __y.value(); |
405 bool | 486 } |
406 operator==(const error_condition& __x, const error_code& __y) _NOEXCEPT | 487 |
407 { | 488 inline _LIBCPP_HIDE_FROM_ABI strong_ordering |
408 return __y == __x; | 489 operator<=>(const error_condition& __x, const error_condition& __y) noexcept |
409 } | 490 { |
410 | 491 if (auto __c = __x.category() <=> __y.category(); __c != 0) |
411 inline _LIBCPP_INLINE_VISIBILITY | 492 return __c; |
412 bool | 493 return __x.value() <=> __y.value(); |
413 operator==(const error_condition& __x, const error_condition& __y) _NOEXCEPT | 494 } |
414 { | 495 |
415 return __x.category() == __y.category() && __x.value() == __y.value(); | 496 #endif // _LIBCPP_STD_VER <= 17 |
416 } | |
417 | |
418 inline _LIBCPP_INLINE_VISIBILITY | |
419 bool | |
420 operator!=(const error_code& __x, const error_code& __y) _NOEXCEPT | |
421 {return !(__x == __y);} | |
422 | |
423 inline _LIBCPP_INLINE_VISIBILITY | |
424 bool | |
425 operator!=(const error_code& __x, const error_condition& __y) _NOEXCEPT | |
426 {return !(__x == __y);} | |
427 | |
428 inline _LIBCPP_INLINE_VISIBILITY | |
429 bool | |
430 operator!=(const error_condition& __x, const error_code& __y) _NOEXCEPT | |
431 {return !(__x == __y);} | |
432 | |
433 inline _LIBCPP_INLINE_VISIBILITY | |
434 bool | |
435 operator!=(const error_condition& __x, const error_condition& __y) _NOEXCEPT | |
436 {return !(__x == __y);} | |
437 | 497 |
438 template <> | 498 template <> |
439 struct _LIBCPP_TEMPLATE_VIS hash<error_code> | 499 struct _LIBCPP_TEMPLATE_VIS hash<error_code> |
440 : public unary_function<error_code, size_t> | 500 : public __unary_function<error_code, size_t> |
441 { | 501 { |
442 _LIBCPP_INLINE_VISIBILITY | 502 _LIBCPP_INLINE_VISIBILITY |
443 size_t operator()(const error_code& __ec) const _NOEXCEPT | 503 size_t operator()(const error_code& __ec) const _NOEXCEPT |
444 { | 504 { |
445 return static_cast<size_t>(__ec.value()); | 505 return static_cast<size_t>(__ec.value()); |
446 } | 506 } |
447 }; | 507 }; |
448 | 508 |
449 template <> | 509 template <> |
450 struct _LIBCPP_TEMPLATE_VIS hash<error_condition> | 510 struct _LIBCPP_TEMPLATE_VIS hash<error_condition> |
451 : public unary_function<error_condition, size_t> | 511 : public __unary_function<error_condition, size_t> |
452 { | 512 { |
453 _LIBCPP_INLINE_VISIBILITY | 513 _LIBCPP_INLINE_VISIBILITY |
454 size_t operator()(const error_condition& __ec) const _NOEXCEPT | 514 size_t operator()(const error_condition& __ec) const _NOEXCEPT |
455 { | 515 { |
456 return static_cast<size_t>(__ec.value()); | 516 return static_cast<size_t>(__ec.value()); |
469 system_error(error_code __ec); | 529 system_error(error_code __ec); |
470 system_error(int __ev, const error_category& __ecat, const string& __what_arg); | 530 system_error(int __ev, const error_category& __ecat, const string& __what_arg); |
471 system_error(int __ev, const error_category& __ecat, const char* __what_arg); | 531 system_error(int __ev, const error_category& __ecat, const char* __what_arg); |
472 system_error(int __ev, const error_category& __ecat); | 532 system_error(int __ev, const error_category& __ecat); |
473 system_error(const system_error&) _NOEXCEPT = default; | 533 system_error(const system_error&) _NOEXCEPT = default; |
474 ~system_error() _NOEXCEPT; | 534 ~system_error() _NOEXCEPT override; |
475 | 535 |
476 _LIBCPP_INLINE_VISIBILITY | 536 _LIBCPP_INLINE_VISIBILITY |
477 const error_code& code() const _NOEXCEPT {return __ec_;} | 537 const error_code& code() const _NOEXCEPT {return __ec_;} |
478 | 538 |
479 private: | 539 private: |
480 static string __init(const error_code&, string); | 540 static string __init(const error_code&, string); |
481 }; | 541 }; |
482 | 542 |
483 _LIBCPP_NORETURN _LIBCPP_FUNC_VIS | 543 _LIBCPP_NORETURN _LIBCPP_FUNC_VIS |
484 void __throw_system_error(int ev, const char* what_arg); | 544 void __throw_system_error(int __ev, const char* __what_arg); |
485 | 545 |
486 _LIBCPP_END_NAMESPACE_STD | 546 _LIBCPP_END_NAMESPACE_STD |
487 | 547 |
488 #endif // _LIBCPP_SYSTEM_ERROR | 548 #endif // _LIBCPP_SYSTEM_ERROR |