1//// 2Copyright 2003-2017 Beman Dawes 3Copyright 2018 Peter Dimov 4 5Distributed under the Boost Software License, Version 1.0. 6 7See accompanying file LICENSE_1_0.txt or copy at 8http://www.boost.org/LICENSE_1_0.txt 9//// 10 11[#reference] 12# Reference 13:idprefix: ref_ 14 15## Use of {cpp}11 and {cpp}14 Features 16 17The library is documented to use several {cpp}11 and {cpp}14 features, 18including `noexcept`, explicit conversion operators and `constexpr`. The 19actual implementation uses {cpp}11 and {cpp}14 features only when they are 20available, and otherwise falls back on {cpp}03 features. 21 22## Macros 23 24When `BOOST_SYSTEM_ENABLE_DEPRECATED` is defined, the library provides 25deprecated features for compatibility. These features are bound to eventually 26disappear. 27 28When `BOOST_SYSTEM_USE_UTF8` is defined, on Windows the library returns 29UTF-8 messages using code page `CP_UTF8` instead of the default `CP_ACP`. 30This macro has no effect on POSIX. 31 32## Deprecated Names 33 34In the process of adding Boost.System to the {cpp}11 standard library, the 35{cpp} committee changed some names. To ease transition, Boost.System deprecates 36the old names, but will provide them when the macro `BOOST_SYSTEM_ENABLE_DEPRECATED` is defined. 37 38|=== 39|Old usage, now deprecated|Replacement 40 41|`get_generic_category()`|`generic_category()` 42|`get_system_category()`|`system_category()` 43|`namespace posix`|`namespace errc` 44|`namespace posix_error`|`namespace errc` 45|`get_posix_category()`|`generic_category()` 46|`posix_category`|`generic_category()` 47|`errno_ecat`|`generic_category()` 48|`native_ecat`|`system_category()` 49|=== 50 51## <boost/system/error_code.hpp> 52 53### Synopsis 54 55``` 56namespace boost { 57 namespace system { 58 59 class error_category; 60 61 constexpr const error_category & system_category() noexcept; 62 constexpr const error_category & generic_category() noexcept; 63 64 class error_code; 65 class error_condition; 66 67 // "Concept" helpers 68 69 template<class T> 70 struct is_error_code_enum { static const bool value = false; }; 71 72 template<class T> 73 struct is_error_condition_enum { static const bool value = false; }; 74 75 // generic error conditions 76 77 namespace errc { 78 enum errc_t 79 { 80 success = 0, 81 address_family_not_supported, //EAFNOSUPPORT 82 address_in_use, //EADDRINUSE 83 address_not_available, //EADDRNOTAVAIL 84 already_connected, //EISCONN 85 argument_list_too_long, //E2BIG 86 argument_out_of_domain, //EDOM 87 bad_address, //EFAULT 88 bad_file_descriptor, //EBADF 89 bad_message, //EBADMSG 90 broken_pipe, //EPIPE 91 connection_aborted, //ECONNABORTED 92 connection_already_in_progress, //EALREADY 93 connection_refused, //ECONNREFUSED 94 connection_reset, //ECONNRESET 95 cross_device_link, //EXDEV 96 destination_address_required, //EDESTADDRREQ 97 device_or_resource_busy, //EBUSY 98 directory_not_empty, //ENOTEMPTY 99 executable_format_error, //ENOEXEC 100 file_exists, //EEXIST 101 file_too_large, //EFBIG 102 filename_too_long, //ENAMETOOLONG 103 function_not_supported, //ENOSYS 104 host_unreachable, //EHOSTUNREACH 105 identifier_removed, //EIDRM 106 illegal_byte_sequence, //EILSEQ 107 inappropriate_io_control_operation, //ENOTTY 108 interrupted, //EINTR 109 invalid_argument, //EINVAL 110 invalid_seek, //ESPIPE 111 io_error, //EIO 112 is_a_directory, //EISDIR 113 message_size, //EMSGSIZE 114 network_down, //ENETDOWN 115 network_reset, //ENETRESET 116 network_unreachable, //ENETUNREACH 117 no_buffer_space, //ENOBUFS 118 no_child_process, //ECHILD 119 no_link, //ENOLINK 120 no_lock_available, //ENOLCK 121 no_message_available, //ENODATA 122 no_message, //ENOMSG 123 no_protocol_option, //ENOPROTOOPT 124 no_space_on_device, //ENOSPC 125 no_stream_resources, //ENOSR 126 no_such_device_or_address, //ENXIO 127 no_such_device, //ENODEV 128 no_such_file_or_directory, //ENOENT 129 no_such_process, //ESRCH 130 not_a_directory, //ENOTDIR 131 not_a_socket, //ENOTSOCK 132 not_a_stream, //ENOSTR 133 not_connected, //ENOTCONN 134 not_enough_memory, //ENOMEM 135 not_supported, //ENOTSUP 136 operation_canceled, //ECANCELED 137 operation_in_progress, //EINPROGRESS 138 operation_not_permitted, //EPERM 139 operation_not_supported, //EOPNOTSUPP 140 operation_would_block, //EWOULDBLOCK 141 owner_dead, //EOWNERDEAD 142 permission_denied, //EACCES 143 protocol_error, //EPROTO 144 protocol_not_supported, //EPROTONOSUPPORT 145 read_only_file_system, //EROFS 146 resource_deadlock_would_occur, //EDEADLK 147 resource_unavailable_try_again, //EAGAIN 148 result_out_of_range, //ERANGE 149 state_not_recoverable, //ENOTRECOVERABLE 150 stream_timeout, //ETIME 151 text_file_busy, //ETXTBSY 152 timed_out, //ETIMEDOUT 153 too_many_files_open_in_system, //ENFILE 154 too_many_files_open, //EMFILE 155 too_many_links, //EMLINK 156 too_many_synbolic_link_levels, //ELOOP 157 value_too_large, //EOVERFLOW 158 wrong_protocol_type //EPROTOTYPE 159 }; 160 161 } // namespace errc 162 163 template<> struct is_error_condition_enum<errc::errc_t> 164 { static const bool value = true; }; 165 166 // non-member functions 167 168 constexpr bool operator==( const error_code & lhs, 169 const error_code & rhs ) noexcept; 170 bool operator==( const error_code & code, 171 const error_condition & condition ) noexcept; 172 bool operator==( const error_condition & condition, 173 const error_code & code ) noexcept; 174 constexpr bool operator==( const error_condition & lhs, 175 const error_condition & rhs ) noexcept; 176 177 constexpr bool operator!=( const error_code & lhs, 178 const error_code & rhs ) noexcept; 179 bool operator!=( const error_code & code, 180 const error_condition & condition ) noexcept; 181 bool operator!=( const error_condition & condition, 182 const error_code & code ) noexcept; 183 constexpr bool operator!=( const error_condition & lhs, 184 const error_condition & rhs ) noexcept; 185 186 constexpr bool operator<( const error_code & lhs, 187 const error_code & rhs ) noexcept; 188 constexpr bool operator<( const error_condition & lhs, 189 const error_condition & rhs ) noexcept; 190 191 constexpr error_code make_error_code( errc::errc_t e ) noexcept; 192 constexpr error_condition make_error_condition( errc::errc_t e ) noexcept; 193 194 template <class charT, class traits> 195 std::basic_ostream<charT, traits>& 196 operator<<( basic_ostream<charT, traits>& os, const error_code & ec ); 197 198 std::size_t hash_value( const error_code & ec ); 199 200 } // namespace system 201} // namespace boost 202``` 203 204The value of each `errc_t` constant is the same as the value of the `<cerrno>` 205macro shown in the above synopsis. 206 207Users may specialize `is_error_code_enum` and `is_error_condition_enum` 208templates to indicate that a type is eligible for class `error_code` and 209`error_condition` automatic conversions respectively. 210 211### Class error_category 212 213The class `error_category` defines the base class for types used 214to identify the source and encoding of a particular category of error code. 215 216Classes may be derived from `error_category` to support categories of 217errors in addition to those defined in Boost.System. 218 219``` 220namespace boost { 221 namespace system { 222 223 class error_category 224 { 225 public: // noncopyable 226 227 error_category( error_category const & ) = delete; 228 error_category& operator=( error_category const & ) = delete; 229 230 protected: 231 232 ~error_category() = default; 233 234 constexpr error_category() noexcept; 235 explicit constexpr error_category( unsigned long long id ) noexcept; 236 237 public: 238 239 virtual const char * name() const noexcept = 0; 240 241 virtual error_condition default_error_condition( int ev ) const noexcept; 242 243 virtual bool equivalent( int code, const error_condition & condition ) 244 const noexcept; 245 virtual bool equivalent( const error_code & code, int condition ) 246 const noexcept; 247 248 virtual std::string message( int ev ) const = 0; 249 virtual char const * message( int ev, char * buffer, std::size_t len ) 250 const noexcept; 251 252 virtual bool failed( int ev ) const noexcept; 253 254 constexpr bool operator==( const error_category & rhs ) const noexcept; 255 constexpr bool operator!=( const error_category & rhs ) const noexcept; 256 constexpr bool operator< ( const error_category & rhs ) const noexcept; 257 258 operator std::error_category const & () const; 259 260 private: 261 262 unsigned long long id_; // exposition only 263 264 }; 265 } 266} 267``` 268 269#### Constructors 270 271``` 272constexpr error_category() noexcept; 273``` 274[none] 275* {blank} 276+ 277Effects: :: Initializes `id_` to 0. 278Remarks: :: Since equivalence for categories that do not have an identifier is 279 based on comparing object addresses, a user-defined derived category of type 280 `C` that uses this constructor should ensure that only one object of type `C` 281 exists in the program. 282 283``` 284explicit constexpr error_category( unsigned long long id ) noexcept; 285``` 286[none] 287* {blank} 288+ 289Effects: :: Initializes `id_` to `id`. 290Remarks: :: User-defined derived categories that use this constructor are considered 291 equivalent when their identifiers match. Therefore, those categories may have more 292 than one instance existing in a program, but to minimize the possibility of 293 collision, their identifiers must be randomly chosen (at the time the category 294 is implemented, not at runtime). One way of generating a 64 bit random identifier 295 is https://www.random.org/cgi-bin/randbyte?nbytes=8&format=h. 296 297#### Virtuals 298 299``` 300virtual const char * name() const noexcept = 0; 301``` 302[none] 303* {blank} 304+ 305Returns: :: In derived classes, a character literal naming the error category. 306 307``` 308virtual error_condition default_error_condition( int ev ) const noexcept; 309``` 310[none] 311* {blank} 312+ 313Returns: :: 314- In derived classes, an error condition corresponding to `ev`. 315 The returned error condition will typically come from the generic category. 316- In the default implementation, `error_condition( ev, *this )`. 317 318``` 319virtual bool equivalent( int code, const error_condition & condition ) 320 const noexcept; 321``` 322[none] 323* {blank} 324+ 325Returns: :: 326- In derived classes, `true` when `error_code( code, *this )` is equivalent to `condition`. 327- In the default implementation, `default_error_condition( code ) == condition`. 328 329``` 330virtual bool equivalent( const error_code & code, int condition ) 331 const noexcept; 332``` 333[none] 334* {blank} 335+ 336Returns: :: 337- In derived classes, `true` when `code` is equivalent to `error_condition( condition, *this )`. 338- In the default implementation, `*this == code.category() && code.value() == condition`. 339 340``` 341virtual std::string message( int ev ) const = 0; 342``` 343[none] 344* {blank} 345+ 346Returns: :: In derived classes, a string that describes the error denoted by `ev`. 347 348``` 349virtual char const * message( int ev, char * buffer, std::size_t len ) 350 const noexcept; 351``` 352[none] 353* {blank} 354+ 355Effects: :: 356** Derived classes should either 357 *** return a pointer to a character literal describing the error denoted by `ev`, or 358 *** copy a string describing the error into `buffer`, truncating it to `len-1` 359 characters and storing a null terminator, and return `buffer`. If `len` is 0, 360 nothing is copied, but the function still returns `buffer`. Note that 361 when `len` is 0, `buffer` may be `nullptr`. 362** The default implementation calls `message(ev)` and copies the result into 363 `buffer`, truncating it to `len-1` characters and storing a null terminator. 364 If `len` is 0, copies nothing. Returns `buffer`. If `message(ev)` throws an 365 exception, the string `"Message text unavailable"` is used. 366Example: :: 367+ 368``` 369const char* my_category::message(int ev, char* buffer, size_t len) const noexcept 370{ 371 switch(ev) 372 { 373 case 0: return "no error"; 374 case 1: return "voltage out of range"; 375 case 2: return "impedance mismatch"; 376 case 31: 377 case 32: 378 case 33: 379 std::snprintf(buffer, len, "component %d failure", ev-30); 380 return buffer; 381 default: 382 std::snprintf(buffer, len, "unknown error %d", ev); 383 return buffer; 384 } 385} 386``` 387 388``` 389virtual bool failed( int ev ) const noexcept; 390``` 391[none] 392* {blank} 393+ 394Returns: :: 395- In derived classes, `true` when `ev` represents a failure. 396- In the default implementation, `ev != 0`. 397Remarks: :: 398 All calls to this function with the same `ev` must return the same value. 399 400#### Nonvirtuals 401 402``` 403constexpr bool operator==( const error_category & rhs ) const noexcept; 404``` 405[none] 406* {blank} 407+ 408Returns: :: `rhs.id_ == 0? this == &rhs: id_ == rhs.id_`. 409Remarks: :: Two category objects are considered equivalent when they have matching 410 nonzero identifiers, or are the same object. 411 412``` 413constexpr bool operator!=( const error_category & rhs ) const noexcept; 414``` 415[none] 416* {blank} 417+ 418Returns: :: `!( *this == rhs )`. 419 420``` 421constexpr bool operator< ( const error_category & rhs ) const noexcept; 422``` 423[none] 424* {blank} 425+ 426Returns: :: 427** If `id_ < rhs.id_`, `true`; 428** Otherwise, if `id_ > rhs.id_`, `false`; 429** Otherwise, if `rhs.id_ != 0`, `false`; 430** Otherwise, `std::less<error_category const *>()( this, &rhs )`. 431 432``` 433operator std::error_category const & () const; 434``` 435[none] 436* {blank} 437+ 438Returns: :: A reference to an `std::error_category` object corresponding 439 to `*this`. 440 441### Predefined Categories 442 443``` 444constexpr const error_category & system_category() noexcept; 445``` 446[none] 447* {blank} 448+ 449Returns: :: A reference to an `error_category` object identifying errors 450 originating from the operating system. 451 452``` 453constexpr const error_category & generic_category() noexcept; 454``` 455[none] 456* {blank} 457+ 458Returns: :: A reference to an `error_category` object identifying portable 459 error conditions. 460 461### Class error_code 462 463The class `error_code` describes an object used to hold error code 464values, such as those originating from the operating system or other 465low-level application program interfaces. It's an adjunct to error reporting 466by exception. 467 468``` 469namespace boost { 470 namespace system { 471 472 class error_code { 473 public: 474 475 // constructors: 476 477 constexpr error_code() noexcept; 478 constexpr error_code( int val, const error_category & cat ) noexcept; 479 480 template <class ErrorCodeEnum> 481 constexpr error_code( ErrorCodeEnum e ) noexcept; 482 483 // modifiers: 484 485 constexpr void assign( int val, const error_category & cat ) noexcept; 486 487 template<typename ErrorCodeEnum> 488 constexpr error_code & operator=( ErrorCodeEnum e ) noexcept; 489 490 constexpr void clear() noexcept; 491 492 // observers: 493 494 constexpr int value() const noexcept; 495 constexpr const error_category & category() const noexcept; 496 497 error_condition default_error_condition() const noexcept; 498 499 std::string message() const; 500 char const * message( char * buffer, std::size_t len ) const noexcept; 501 502 constexpr bool failed() const noexcept; 503 constexpr explicit operator bool() const noexcept; 504 505 operator std::error_code() const; 506 507 private: // exposition only 508 509 int val_; 510 const error_category * cat_; 511 512 }; 513 } 514} 515``` 516 517#### Constructors 518 519``` 520constexpr error_code() noexcept; 521``` 522[none] 523* {blank} 524+ 525Ensures: :: `val_ == 0`; `*cat_ == system_category()`. 526 527``` 528constexpr error_code( int val, const error_category & cat ) noexcept; 529``` 530[none] 531* {blank} 532+ 533Ensures: :: `val_ == val`; `cat_ == &cat`. 534 535``` 536template <class ErrorCodeEnum> 537 constexpr error_code( ErrorCodeEnum e ) noexcept; 538``` 539[none] 540* {blank} 541+ 542Ensures: :: `*this == make_error_code( e )`. 543Remarks: :: This constructor is only enabled when `is_error_code_enum<ErrorCodeEnum>::value` is `true`. 544 545#### Modifiers 546 547``` 548constexpr void assign( int val, const error_category & cat ) noexcept; 549``` 550[none] 551* {blank} 552+ 553Ensures: :: `val_ == val`; `cat_ == &cat`. 554 555``` 556template<typename ErrorCodeEnum> 557 constexpr error_code & operator=( ErrorCodeEnum e ) noexcept; 558``` 559[none] 560* {blank} 561+ 562Ensures: :: `*this == make_error_code( e )`. 563Remarks: :: This operator is only enabled when `is_error_code_enum<ErrorCodeEnum>::value` is `true`. 564 565``` 566constexpr void clear() noexcept; 567``` 568[none] 569* {blank} 570+ 571Ensures: :: 572 `val_ == 0`; `*cat_ == system_category()`. 573 574#### Observers 575 576``` 577constexpr int value() const noexcept; 578``` 579[none] 580* {blank} 581+ 582Returns: :: `val_`. 583 584``` 585constexpr const error_category & category() const noexcept; 586``` 587[none] 588* {blank} 589+ 590Returns: :: `*cat_`. 591 592``` 593error_condition default_error_condition() const noexcept; 594``` 595[none] 596* {blank} 597+ 598Returns: :: `cat_\->default_error_condition( val_ )`. 599 600``` 601std::string message() const; 602``` 603[none] 604* {blank} 605+ 606Returns: :: `cat_\->message( val_ )`. 607 608``` 609char const * message( char * buffer, std::size_t len ) const noexcept; 610``` 611[none] 612* {blank} 613+ 614Returns: :: `cat_\->message( val_, buffer, len )`. 615 616``` 617constexpr bool failed() const noexcept; 618``` 619[none] 620* {blank} 621+ 622Returns: :: `cat_\->failed( val_ )`. 623 624``` 625constexpr explicit operator bool() const noexcept; 626``` 627[none] 628* {blank} 629+ 630Returns: :: `failed()`. 631 632``` 633operator std::error_code() const; 634``` 635[none] 636* {blank} 637+ 638Returns: :: 639 `std::error_code( val_, *cat_ )`. 640 641### Class error_condition 642 643``` 644namespace boost { 645 namespace system { 646 647 class error_condition { 648 public: 649 650 // constructors: 651 652 constexpr error_condition() noexcept; 653 constexpr error_condition( int val, const error_category & cat ) noexcept; 654 655 template <class ErrorConditionEnum> 656 constexpr error_condition( ErrorConditionEnum e ) noexcept; 657 658 // modifiers: 659 660 constexpr void assign( int val, const error_category & cat ) noexcept; 661 662 template<typename ErrorConditionEnum> 663 constexpr error_condition & operator=( ErrorConditionEnum e ) noexcept; 664 665 constexpr void clear() noexcept; 666 667 // observers: 668 669 constexpr int value() const noexcept; 670 constexpr const error_category & category() const noexcept; 671 672 std::string message() const; 673 char const * message( char * buffer, std::size_t len ) const noexcept; 674 675 constexpr bool failed() const noexcept; 676 constexpr explicit operator bool() const noexcept; 677 678 operator std::error_condition() const; 679 680 private: // exposition only 681 682 int val_; 683 const error_category * cat_; 684 685 }; 686 } 687} 688``` 689 690#### Constructors 691 692``` 693constexpr error_condition() noexcept; 694``` 695[none] 696* {blank} 697+ 698Ensures: :: `val_ == 0`; `*cat_ == generic_category()`. 699 700``` 701constexpr error_condition( int val, const error_category & cat ) noexcept; 702``` 703[none] 704* {blank} 705+ 706Ensures: :: `val_ == val`; `cat_ == &cat`. 707 708``` 709template <class ErrorConditionEnum> 710 constexpr error_condition( ErrorConditionEnum e ) noexcept; 711``` 712[none] 713* {blank} 714+ 715Ensures: :: `*this == make_error_condition( e )`. 716Remarks: :: 717 This constructor is only enabled when `is_error_condition_enum<ErrorConditionEnum>::value` is `true`. 718 719#### Modifiers 720 721``` 722constexpr void assign( int val, const error_category & cat ) noexcept; 723``` 724[none] 725* {blank} 726+ 727Ensures: :: `val_ == val`; `cat_ == &cat`. 728 729``` 730template <class ErrorConditionEnum> 731 constexpr error_condition & operator=( ErrorConditionEnum e ) noexcept; 732``` 733[none] 734* {blank} 735+ 736Ensures: :: `*this == make_error_condition( e )`. 737Remarks: :: This operator is only enabled when `is_error_condition_enum<ErrorConditionEnum>::value` is `true`. 738 739``` 740constexpr void clear() noexcept; 741``` 742[none] 743* {blank} 744+ 745Ensures: :: 746 `val_ == 0`; `*cat_ == generic_category()`. 747 748#### Observers 749 750``` 751constexpr int value() const noexcept; 752``` 753[none] 754* {blank} 755+ 756Returns: :: `val_`. 757 758``` 759constexpr const error_category & category() const noexcept; 760``` 761[none] 762* {blank} 763+ 764Returns: :: `*cat_`. 765 766``` 767std::string message() const; 768``` 769[none] 770* {blank} 771+ 772Returns: :: `cat_\->message( val_ )`. 773 774``` 775char const * message( char * buffer, std::size_t len ) const noexcept; 776``` 777[none] 778* {blank} 779+ 780Returns: :: `cat_\->message( val_, buffer, len )`. 781 782``` 783constexpr bool failed() const noexcept; 784``` 785[none] 786* {blank} 787+ 788Returns: :: `cat_\->failed( val_ )`. 789 790``` 791constexpr explicit operator bool() const noexcept; 792``` 793[none] 794* {blank} 795+ 796Returns: :: `failed()`. 797 798``` 799operator std::error_condition() const; 800``` 801[none] 802* {blank} 803+ 804Returns: :: 805 `std::error_condition( val_, *cat_ )`. 806 807### Nonmember functions 808 809``` 810constexpr bool operator==( const error_code & lhs, 811 const error_code & rhs ) noexcept; 812constexpr bool operator==( const error_condition & lhs, 813 const error_condition & rhs ) noexcept; 814``` 815[none] 816* {blank} 817+ 818Returns: :: `lhs.value() == rhs.value() && lhs.category() == rhs.category()`. 819 820``` 821bool operator==( const error_code & code, 822 const error_condition & condition ) noexcept; 823bool operator==( const error_condition & condition, 824 const error_code & code ) noexcept; 825``` 826[none] 827* {blank} 828+ 829Returns: :: `code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() )`. 830 831``` 832constexpr bool operator!=( const error_code & lhs, 833 const error_code & rhs ) noexcept; 834constexpr bool operator!=( const error_condition & lhs, 835 const error_condition & rhs ) noexcept; 836bool operator!=( const error_code & code, 837 const error_condition & condition ) noexcept; 838bool operator!=( const error_condition & condition, 839 const error_code & code ) noexcept; 840``` 841[none] 842* {blank} 843+ 844Returns: :: `!( lhs == rhs )`. 845 846``` 847constexpr bool operator<( const error_code & lhs, 848 const error_code & rhs ) noexcept; 849constexpr bool operator<( const error_condition & lhs, 850 const error_condition & rhs ) noexcept; 851``` 852[none] 853* {blank} 854+ 855Returns: :: `lhs.category() < rhs.category() || ( lhs.category() == rhs.category() && lhs.value() < rhs.value() )`. 856 857``` 858constexpr error_code make_error_code( errc::errc_t e ) noexcept; 859``` 860[none] 861* {blank} 862+ 863Returns: :: `error_code( e, generic_category() )`. 864 865``` 866constexpr error_condition make_error_condition( errc::errc_t e ) noexcept; 867``` 868[none] 869* {blank} 870+ 871Returns: :: `error_condition( e, generic_category() )`. 872 873``` 874template <class charT, class traits> 875 std::basic_ostream<charT, traits>& 876 operator<<( basic_ostream<charT, traits>& os, const error_code & ec ); 877``` 878[none] 879* {blank} 880+ 881Effects: :: `os << ec.category().name() << ':' << ec.value()`. 882Returns: :: `os`. 883 884``` 885std::size_t hash_value( const error_code & ec ); 886``` 887[none] 888* {blank} 889+ 890Returns: :: 891 A hash value representing `ec`. 892 893## <boost/system/system_error.hpp> 894 895### Class system_error 896 897The class `system_error` describes an exception object used to 898report errors that have an associated `error_code`. Such errors 899typically originate from operating system or other low-level 900application program interfaces. 901 902``` 903namespace boost 904{ 905 namespace system 906 { 907 class system_error: public std::runtime_error 908 { 909 public: 910 911 explicit system_error( error_code ec ); 912 system_error( error_code ec, const char * what_arg ); 913 system_error( error_code ec, const std::string & what_arg ); 914 915 system_error( int ev, const error_category & ecat ); 916 system_error( int ev, const error_category & ecat, 917 const char * what_arg ); 918 system_error( int ev, const error_category & ecat, 919 const std::string & what_arg ); 920 921 error_code code() const noexcept; 922 const char * what() const noexcept; 923 }; 924 } 925} 926``` 927 928#### Constructors 929 930``` 931explicit system_error( error_code ec ); 932system_error( error_code ec, const char * what_arg ); 933system_error( error_code ec, const std::string & what_arg ); 934``` 935[none] 936* {blank} 937+ 938Ensures: :: `code() == ec`. 939 940``` 941system_error( int ev, const error_category & ecat, 942 const char * what_arg ); 943system_error( int ev, const error_category & ecat, 944 const std::string & what_arg ); 945system_error( int ev, const error_category & ecat ); 946``` 947[none] 948* {blank} 949+ 950Ensures: :: 951 `code() == error_code( ev, ecat )`. 952 953#### Observers 954 955``` 956error_code code() const noexcept; 957``` 958[none] 959* {blank} 960+ 961Returns: :: `ec` or `error_code( ev, ecat )`, from the constructor, as appropriate. 962 963``` 964const char * what() const noexcept; 965``` 966[none] 967* {blank} 968+ 969Returns: :: A null-terminated character string incorporating the arguments supplied 970 in the constructor, typically of the form `what_arg + ": " + code.message()`. 971