system_error 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. // -*- C++ -*-
  2. //===---------------------------- system_error ----------------------------===//
  3. //
  4. // The LLVM Compiler Infrastructure
  5. //
  6. // This file is dual licensed under the MIT and the University of Illinois Open
  7. // Source Licenses. See LICENSE.TXT for details.
  8. //
  9. //===----------------------------------------------------------------------===//
  10. #ifndef _LIBCPP_SYSTEM_ERROR
  11. #define _LIBCPP_SYSTEM_ERROR
  12. /*
  13. system_error synopsis
  14. namespace std
  15. {
  16. class error_category
  17. {
  18. public:
  19. virtual ~error_category() noexcept;
  20. constexpr error_category();
  21. error_category(const error_category&) = delete;
  22. error_category& operator=(const error_category&) = delete;
  23. virtual const char* name() const noexcept = 0;
  24. virtual error_condition default_error_condition(int ev) const noexcept;
  25. virtual bool equivalent(int code, const error_condition& condition) const noexcept;
  26. virtual bool equivalent(const error_code& code, int condition) const noexcept;
  27. virtual string message(int ev) const = 0;
  28. bool operator==(const error_category& rhs) const noexcept;
  29. bool operator!=(const error_category& rhs) const noexcept;
  30. bool operator<(const error_category& rhs) const noexcept;
  31. };
  32. const error_category& generic_category() noexcept;
  33. const error_category& system_category() noexcept;
  34. template <class T> struct is_error_code_enum
  35. : public false_type {};
  36. template <class T> struct is_error_condition_enum
  37. : public false_type {};
  38. class error_code
  39. {
  40. public:
  41. // constructors:
  42. error_code() noexcept;
  43. error_code(int val, const error_category& cat) noexcept;
  44. template <class ErrorCodeEnum>
  45. error_code(ErrorCodeEnum e) noexcept;
  46. // modifiers:
  47. void assign(int val, const error_category& cat) noexcept;
  48. template <class ErrorCodeEnum>
  49. error_code& operator=(ErrorCodeEnum e) noexcept;
  50. void clear() noexcept;
  51. // observers:
  52. int value() const noexcept;
  53. const error_category& category() const noexcept;
  54. error_condition default_error_condition() const noexcept;
  55. string message() const;
  56. explicit operator bool() const noexcept;
  57. };
  58. // non-member functions:
  59. bool operator<(const error_code& lhs, const error_code& rhs) noexcept;
  60. template <class charT, class traits>
  61. basic_ostream<charT,traits>&
  62. operator<<(basic_ostream<charT,traits>& os, const error_code& ec);
  63. class error_condition
  64. {
  65. public:
  66. // constructors:
  67. error_condition() noexcept;
  68. error_condition(int val, const error_category& cat) noexcept;
  69. template <class ErrorConditionEnum>
  70. error_condition(ErrorConditionEnum e) noexcept;
  71. // modifiers:
  72. void assign(int val, const error_category& cat) noexcept;
  73. template <class ErrorConditionEnum>
  74. error_condition& operator=(ErrorConditionEnum e) noexcept;
  75. void clear() noexcept;
  76. // observers:
  77. int value() const noexcept;
  78. const error_category& category() const noexcept;
  79. string message() const noexcept;
  80. explicit operator bool() const noexcept;
  81. };
  82. bool operator<(const error_condition& lhs, const error_condition& rhs) noexcept;
  83. class system_error
  84. : public runtime_error
  85. {
  86. public:
  87. system_error(error_code ec, const string& what_arg);
  88. system_error(error_code ec, const char* what_arg);
  89. system_error(error_code ec);
  90. system_error(int ev, const error_category& ecat, const string& what_arg);
  91. system_error(int ev, const error_category& ecat, const char* what_arg);
  92. system_error(int ev, const error_category& ecat);
  93. const error_code& code() const noexcept;
  94. const char* what() const noexcept;
  95. };
  96. enum class errc
  97. {
  98. address_family_not_supported, // EAFNOSUPPORT
  99. address_in_use, // EADDRINUSE
  100. address_not_available, // EADDRNOTAVAIL
  101. already_connected, // EISCONN
  102. argument_list_too_long, // E2BIG
  103. argument_out_of_domain, // EDOM
  104. bad_address, // EFAULT
  105. bad_file_descriptor, // EBADF
  106. bad_message, // EBADMSG
  107. broken_pipe, // EPIPE
  108. connection_aborted, // ECONNABORTED
  109. connection_already_in_progress, // EALREADY
  110. connection_refused, // ECONNREFUSED
  111. connection_reset, // ECONNRESET
  112. cross_device_link, // EXDEV
  113. destination_address_required, // EDESTADDRREQ
  114. device_or_resource_busy, // EBUSY
  115. directory_not_empty, // ENOTEMPTY
  116. executable_format_error, // ENOEXEC
  117. file_exists, // EEXIST
  118. file_too_large, // EFBIG
  119. filename_too_long, // ENAMETOOLONG
  120. function_not_supported, // ENOSYS
  121. host_unreachable, // EHOSTUNREACH
  122. identifier_removed, // EIDRM
  123. illegal_byte_sequence, // EILSEQ
  124. inappropriate_io_control_operation, // ENOTTY
  125. interrupted, // EINTR
  126. invalid_argument, // EINVAL
  127. invalid_seek, // ESPIPE
  128. io_error, // EIO
  129. is_a_directory, // EISDIR
  130. message_size, // EMSGSIZE
  131. network_down, // ENETDOWN
  132. network_reset, // ENETRESET
  133. network_unreachable, // ENETUNREACH
  134. no_buffer_space, // ENOBUFS
  135. no_child_process, // ECHILD
  136. no_link, // ENOLINK
  137. no_lock_available, // ENOLCK
  138. no_message_available, // ENODATA
  139. no_message, // ENOMSG
  140. no_protocol_option, // ENOPROTOOPT
  141. no_space_on_device, // ENOSPC
  142. no_stream_resources, // ENOSR
  143. no_such_device_or_address, // ENXIO
  144. no_such_device, // ENODEV
  145. no_such_file_or_directory, // ENOENT
  146. no_such_process, // ESRCH
  147. not_a_directory, // ENOTDIR
  148. not_a_socket, // ENOTSOCK
  149. not_a_stream, // ENOSTR
  150. not_connected, // ENOTCONN
  151. not_enough_memory, // ENOMEM
  152. not_supported, // ENOTSUP
  153. operation_canceled, // ECANCELED
  154. operation_in_progress, // EINPROGRESS
  155. operation_not_permitted, // EPERM
  156. operation_not_supported, // EOPNOTSUPP
  157. operation_would_block, // EWOULDBLOCK
  158. owner_dead, // EOWNERDEAD
  159. permission_denied, // EACCES
  160. protocol_error, // EPROTO
  161. protocol_not_supported, // EPROTONOSUPPORT
  162. read_only_file_system, // EROFS
  163. resource_deadlock_would_occur, // EDEADLK
  164. resource_unavailable_try_again, // EAGAIN
  165. result_out_of_range, // ERANGE
  166. state_not_recoverable, // ENOTRECOVERABLE
  167. stream_timeout, // ETIME
  168. text_file_busy, // ETXTBSY
  169. timed_out, // ETIMEDOUT
  170. too_many_files_open_in_system, // ENFILE
  171. too_many_files_open, // EMFILE
  172. too_many_links, // EMLINK
  173. too_many_symbolic_link_levels, // ELOOP
  174. value_too_large, // EOVERFLOW
  175. wrong_protocol_type // EPROTOTYPE
  176. };
  177. template <> struct is_error_condition_enum<errc>
  178. : true_type { }
  179. error_code make_error_code(errc e) noexcept;
  180. error_condition make_error_condition(errc e) noexcept;
  181. // Comparison operators:
  182. bool operator==(const error_code& lhs, const error_code& rhs) noexcept;
  183. bool operator==(const error_code& lhs, const error_condition& rhs) noexcept;
  184. bool operator==(const error_condition& lhs, const error_code& rhs) noexcept;
  185. bool operator==(const error_condition& lhs, const error_condition& rhs) noexcept;
  186. bool operator!=(const error_code& lhs, const error_code& rhs) noexcept;
  187. bool operator!=(const error_code& lhs, const error_condition& rhs) noexcept;
  188. bool operator!=(const error_condition& lhs, const error_code& rhs) noexcept;
  189. bool operator!=(const error_condition& lhs, const error_condition& rhs) noexcept;
  190. template <> struct hash<std::error_code>;
  191. } // std
  192. */
  193. #include <__config>
  194. #include <cerrno>
  195. #include <type_traits>
  196. #include <stdexcept>
  197. #include <__functional_base>
  198. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  199. #pragma GCC system_header
  200. #endif
  201. _LIBCPP_BEGIN_NAMESPACE_STD
  202. // is_error_code_enum
  203. template <class _Tp>
  204. struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum
  205. : public false_type {};
  206. // is_error_condition_enum
  207. template <class _Tp>
  208. struct _LIBCPP_TYPE_VIS_ONLY is_error_condition_enum
  209. : public false_type {};
  210. // Some error codes are not present on all platforms, so we provide equivalents
  211. // for them:
  212. //enum class errc
  213. _LIBCPP_DECLARE_STRONG_ENUM(errc)
  214. {
  215. address_family_not_supported = EAFNOSUPPORT,
  216. address_in_use = EADDRINUSE,
  217. address_not_available = EADDRNOTAVAIL,
  218. already_connected = EISCONN,
  219. argument_list_too_long = E2BIG,
  220. argument_out_of_domain = EDOM,
  221. bad_address = EFAULT,
  222. bad_file_descriptor = EBADF,
  223. bad_message = EBADMSG,
  224. broken_pipe = EPIPE,
  225. connection_aborted = ECONNABORTED,
  226. connection_already_in_progress = EALREADY,
  227. connection_refused = ECONNREFUSED,
  228. connection_reset = ECONNRESET,
  229. cross_device_link = EXDEV,
  230. destination_address_required = EDESTADDRREQ,
  231. device_or_resource_busy = EBUSY,
  232. directory_not_empty = ENOTEMPTY,
  233. executable_format_error = ENOEXEC,
  234. file_exists = EEXIST,
  235. file_too_large = EFBIG,
  236. filename_too_long = ENAMETOOLONG,
  237. function_not_supported = ENOSYS,
  238. host_unreachable = EHOSTUNREACH,
  239. identifier_removed = EIDRM,
  240. illegal_byte_sequence = EILSEQ,
  241. inappropriate_io_control_operation = ENOTTY,
  242. interrupted = EINTR,
  243. invalid_argument = EINVAL,
  244. invalid_seek = ESPIPE,
  245. io_error = EIO,
  246. is_a_directory = EISDIR,
  247. message_size = EMSGSIZE,
  248. network_down = ENETDOWN,
  249. network_reset = ENETRESET,
  250. network_unreachable = ENETUNREACH,
  251. no_buffer_space = ENOBUFS,
  252. no_child_process = ECHILD,
  253. no_link = ENOLINK,
  254. no_lock_available = ENOLCK,
  255. #ifdef ENODATA
  256. no_message_available = ENODATA,
  257. #else
  258. no_message_available = ENOMSG,
  259. #endif
  260. no_message = ENOMSG,
  261. no_protocol_option = ENOPROTOOPT,
  262. no_space_on_device = ENOSPC,
  263. #ifdef ENOSR
  264. no_stream_resources = ENOSR,
  265. #else
  266. no_stream_resources = ENOMEM,
  267. #endif
  268. no_such_device_or_address = ENXIO,
  269. no_such_device = ENODEV,
  270. no_such_file_or_directory = ENOENT,
  271. no_such_process = ESRCH,
  272. not_a_directory = ENOTDIR,
  273. not_a_socket = ENOTSOCK,
  274. #ifdef ENOSTR
  275. not_a_stream = ENOSTR,
  276. #else
  277. not_a_stream = EINVAL,
  278. #endif
  279. not_connected = ENOTCONN,
  280. not_enough_memory = ENOMEM,
  281. not_supported = ENOTSUP,
  282. operation_canceled = ECANCELED,
  283. operation_in_progress = EINPROGRESS,
  284. operation_not_permitted = EPERM,
  285. operation_not_supported = EOPNOTSUPP,
  286. operation_would_block = EWOULDBLOCK,
  287. owner_dead = EOWNERDEAD,
  288. permission_denied = EACCES,
  289. protocol_error = EPROTO,
  290. protocol_not_supported = EPROTONOSUPPORT,
  291. read_only_file_system = EROFS,
  292. resource_deadlock_would_occur = EDEADLK,
  293. resource_unavailable_try_again = EAGAIN,
  294. result_out_of_range = ERANGE,
  295. state_not_recoverable = ENOTRECOVERABLE,
  296. #ifdef ETIME
  297. stream_timeout = ETIME,
  298. #else
  299. stream_timeout = ETIMEDOUT,
  300. #endif
  301. text_file_busy = ETXTBSY,
  302. timed_out = ETIMEDOUT,
  303. too_many_files_open_in_system = ENFILE,
  304. too_many_files_open = EMFILE,
  305. too_many_links = EMLINK,
  306. too_many_symbolic_link_levels = ELOOP,
  307. value_too_large = EOVERFLOW,
  308. wrong_protocol_type = EPROTOTYPE
  309. };
  310. _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc)
  311. template <>
  312. struct _LIBCPP_TYPE_VIS_ONLY is_error_condition_enum<errc>
  313. : true_type { };
  314. #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
  315. template <>
  316. struct _LIBCPP_TYPE_VIS_ONLY is_error_condition_enum<errc::__lx>
  317. : true_type { };
  318. #endif
  319. class _LIBCPP_TYPE_VIS error_condition;
  320. class _LIBCPP_TYPE_VIS error_code;
  321. // class error_category
  322. class _LIBCPP_HIDDEN __do_message;
  323. class _LIBCPP_TYPE_VIS error_category
  324. {
  325. public:
  326. virtual ~error_category() _NOEXCEPT;
  327. #ifdef _LIBCPP_BUILDING_SYSTEM_ERROR
  328. error_category() _NOEXCEPT;
  329. #else
  330. _LIBCPP_ALWAYS_INLINE
  331. _LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT _LIBCPP_DEFAULT
  332. #endif
  333. private:
  334. error_category(const error_category&);// = delete;
  335. error_category& operator=(const error_category&);// = delete;
  336. public:
  337. virtual const char* name() const _NOEXCEPT = 0;
  338. virtual error_condition default_error_condition(int __ev) const _NOEXCEPT;
  339. virtual bool equivalent(int __code, const error_condition& __condition) const _NOEXCEPT;
  340. virtual bool equivalent(const error_code& __code, int __condition) const _NOEXCEPT;
  341. virtual string message(int __ev) const = 0;
  342. _LIBCPP_ALWAYS_INLINE
  343. bool operator==(const error_category& __rhs) const _NOEXCEPT {return this == &__rhs;}
  344. _LIBCPP_ALWAYS_INLINE
  345. bool operator!=(const error_category& __rhs) const _NOEXCEPT {return !(*this == __rhs);}
  346. _LIBCPP_ALWAYS_INLINE
  347. bool operator< (const error_category& __rhs) const _NOEXCEPT {return this < &__rhs;}
  348. friend class _LIBCPP_HIDDEN __do_message;
  349. };
  350. class _LIBCPP_HIDDEN __do_message
  351. : public error_category
  352. {
  353. public:
  354. virtual string message(int ev) const;
  355. };
  356. _LIBCPP_FUNC_VIS const error_category& generic_category() _NOEXCEPT;
  357. _LIBCPP_FUNC_VIS const error_category& system_category() _NOEXCEPT;
  358. class _LIBCPP_TYPE_VIS error_condition
  359. {
  360. int __val_;
  361. const error_category* __cat_;
  362. public:
  363. _LIBCPP_ALWAYS_INLINE
  364. error_condition() _NOEXCEPT : __val_(0), __cat_(&generic_category()) {}
  365. _LIBCPP_ALWAYS_INLINE
  366. error_condition(int __val, const error_category& __cat) _NOEXCEPT
  367. : __val_(__val), __cat_(&__cat) {}
  368. template <class _Ep>
  369. _LIBCPP_ALWAYS_INLINE
  370. error_condition(_Ep __e,
  371. typename enable_if<is_error_condition_enum<_Ep>::value>::type* = 0
  372. ) _NOEXCEPT
  373. {*this = make_error_condition(__e);}
  374. _LIBCPP_ALWAYS_INLINE
  375. void assign(int __val, const error_category& __cat) _NOEXCEPT
  376. {
  377. __val_ = __val;
  378. __cat_ = &__cat;
  379. }
  380. template <class _Ep>
  381. _LIBCPP_ALWAYS_INLINE
  382. typename enable_if
  383. <
  384. is_error_condition_enum<_Ep>::value,
  385. error_condition&
  386. >::type
  387. operator=(_Ep __e) _NOEXCEPT
  388. {*this = make_error_condition(__e); return *this;}
  389. _LIBCPP_ALWAYS_INLINE
  390. void clear() _NOEXCEPT
  391. {
  392. __val_ = 0;
  393. __cat_ = &generic_category();
  394. }
  395. _LIBCPP_ALWAYS_INLINE
  396. int value() const _NOEXCEPT {return __val_;}
  397. _LIBCPP_ALWAYS_INLINE
  398. const error_category& category() const _NOEXCEPT {return *__cat_;}
  399. string message() const;
  400. _LIBCPP_ALWAYS_INLINE
  401. _LIBCPP_EXPLICIT
  402. operator bool() const _NOEXCEPT {return __val_ != 0;}
  403. };
  404. inline _LIBCPP_INLINE_VISIBILITY
  405. error_condition
  406. make_error_condition(errc __e) _NOEXCEPT
  407. {
  408. return error_condition(static_cast<int>(__e), generic_category());
  409. }
  410. inline _LIBCPP_INLINE_VISIBILITY
  411. bool
  412. operator<(const error_condition& __x, const error_condition& __y) _NOEXCEPT
  413. {
  414. return __x.category() < __y.category()
  415. || (__x.category() == __y.category() && __x.value() < __y.value());
  416. }
  417. // error_code
  418. class _LIBCPP_TYPE_VIS error_code
  419. {
  420. int __val_;
  421. const error_category* __cat_;
  422. public:
  423. _LIBCPP_ALWAYS_INLINE
  424. error_code() _NOEXCEPT : __val_(0), __cat_(&system_category()) {}
  425. _LIBCPP_ALWAYS_INLINE
  426. error_code(int __val, const error_category& __cat) _NOEXCEPT
  427. : __val_(__val), __cat_(&__cat) {}
  428. template <class _Ep>
  429. _LIBCPP_ALWAYS_INLINE
  430. error_code(_Ep __e,
  431. typename enable_if<is_error_code_enum<_Ep>::value>::type* = 0
  432. ) _NOEXCEPT
  433. {*this = make_error_code(__e);}
  434. _LIBCPP_ALWAYS_INLINE
  435. void assign(int __val, const error_category& __cat) _NOEXCEPT
  436. {
  437. __val_ = __val;
  438. __cat_ = &__cat;
  439. }
  440. template <class _Ep>
  441. _LIBCPP_ALWAYS_INLINE
  442. typename enable_if
  443. <
  444. is_error_code_enum<_Ep>::value,
  445. error_code&
  446. >::type
  447. operator=(_Ep __e) _NOEXCEPT
  448. {*this = make_error_code(__e); return *this;}
  449. _LIBCPP_ALWAYS_INLINE
  450. void clear() _NOEXCEPT
  451. {
  452. __val_ = 0;
  453. __cat_ = &system_category();
  454. }
  455. _LIBCPP_ALWAYS_INLINE
  456. int value() const _NOEXCEPT {return __val_;}
  457. _LIBCPP_ALWAYS_INLINE
  458. const error_category& category() const _NOEXCEPT {return *__cat_;}
  459. _LIBCPP_ALWAYS_INLINE
  460. error_condition default_error_condition() const _NOEXCEPT
  461. {return __cat_->default_error_condition(__val_);}
  462. string message() const;
  463. _LIBCPP_ALWAYS_INLINE
  464. _LIBCPP_EXPLICIT
  465. operator bool() const _NOEXCEPT {return __val_ != 0;}
  466. };
  467. inline _LIBCPP_INLINE_VISIBILITY
  468. error_code
  469. make_error_code(errc __e) _NOEXCEPT
  470. {
  471. return error_code(static_cast<int>(__e), generic_category());
  472. }
  473. inline _LIBCPP_INLINE_VISIBILITY
  474. bool
  475. operator<(const error_code& __x, const error_code& __y) _NOEXCEPT
  476. {
  477. return __x.category() < __y.category()
  478. || (__x.category() == __y.category() && __x.value() < __y.value());
  479. }
  480. inline _LIBCPP_INLINE_VISIBILITY
  481. bool
  482. operator==(const error_code& __x, const error_code& __y) _NOEXCEPT
  483. {
  484. return __x.category() == __y.category() && __x.value() == __y.value();
  485. }
  486. inline _LIBCPP_INLINE_VISIBILITY
  487. bool
  488. operator==(const error_code& __x, const error_condition& __y) _NOEXCEPT
  489. {
  490. return __x.category().equivalent(__x.value(), __y)
  491. || __y.category().equivalent(__x, __y.value());
  492. }
  493. inline _LIBCPP_INLINE_VISIBILITY
  494. bool
  495. operator==(const error_condition& __x, const error_code& __y) _NOEXCEPT
  496. {
  497. return __y == __x;
  498. }
  499. inline _LIBCPP_INLINE_VISIBILITY
  500. bool
  501. operator==(const error_condition& __x, const error_condition& __y) _NOEXCEPT
  502. {
  503. return __x.category() == __y.category() && __x.value() == __y.value();
  504. }
  505. inline _LIBCPP_INLINE_VISIBILITY
  506. bool
  507. operator!=(const error_code& __x, const error_code& __y) _NOEXCEPT
  508. {return !(__x == __y);}
  509. inline _LIBCPP_INLINE_VISIBILITY
  510. bool
  511. operator!=(const error_code& __x, const error_condition& __y) _NOEXCEPT
  512. {return !(__x == __y);}
  513. inline _LIBCPP_INLINE_VISIBILITY
  514. bool
  515. operator!=(const error_condition& __x, const error_code& __y) _NOEXCEPT
  516. {return !(__x == __y);}
  517. inline _LIBCPP_INLINE_VISIBILITY
  518. bool
  519. operator!=(const error_condition& __x, const error_condition& __y) _NOEXCEPT
  520. {return !(__x == __y);}
  521. template <>
  522. struct _LIBCPP_TYPE_VIS_ONLY hash<error_code>
  523. : public unary_function<error_code, size_t>
  524. {
  525. _LIBCPP_INLINE_VISIBILITY
  526. size_t operator()(const error_code& __ec) const _NOEXCEPT
  527. {
  528. return static_cast<size_t>(__ec.value());
  529. }
  530. };
  531. // system_error
  532. class _LIBCPP_TYPE_VIS system_error
  533. : public runtime_error
  534. {
  535. error_code __ec_;
  536. public:
  537. system_error(error_code __ec, const string& __what_arg);
  538. system_error(error_code __ec, const char* __what_arg);
  539. system_error(error_code __ec);
  540. system_error(int __ev, const error_category& __ecat, const string& __what_arg);
  541. system_error(int __ev, const error_category& __ecat, const char* __what_arg);
  542. system_error(int __ev, const error_category& __ecat);
  543. ~system_error() _NOEXCEPT;
  544. _LIBCPP_ALWAYS_INLINE
  545. const error_code& code() const _NOEXCEPT {return __ec_;}
  546. private:
  547. static string __init(const error_code&, string);
  548. };
  549. _LIBCPP_FUNC_VIS void __throw_system_error(int ev, const char* what_arg);
  550. _LIBCPP_END_NAMESPACE_STD
  551. #endif // _LIBCPP_SYSTEM_ERROR