diff --git a/doc/system/reference.adoc b/doc/system/reference.adoc index d2d4e00..7bce244 100644 --- a/doc/system/reference.adoc +++ b/doc/system/reference.adoc @@ -54,12 +54,12 @@ the old names, but will provide them when the macro `BOOST_SYSTEM_ENABLE_DEPRECA ``` namespace boost { - namespace system { +namespace system { - template - struct is_error_code_enum { static const bool value = false; }; +template + struct is_error_code_enum { static const bool value = false; }; - } // namespace system +} // namespace system } // namespace boost ``` @@ -74,12 +74,12 @@ be provided in the same namespace as the enumeration type. ``` namespace boost { - namespace system { +namespace system { - template - struct is_error_condition_enum { static const bool value = false; }; +template + struct is_error_condition_enum { static const bool value = false; }; - } // namespace system +} // namespace system } // namespace boost ``` @@ -94,101 +94,101 @@ should be provided in the same namespace as the enumeration type. ``` namespace boost { - namespace system { +namespace system { - namespace errc { - enum errc_t - { - success = 0, - address_family_not_supported, //EAFNOSUPPORT - address_in_use, //EADDRINUSE - address_not_available, //EADDRNOTAVAIL - already_connected, //EISCONN - argument_list_too_long, //E2BIG - argument_out_of_domain, //EDOM - bad_address, //EFAULT - bad_file_descriptor, //EBADF - bad_message, //EBADMSG - broken_pipe, //EPIPE - connection_aborted, //ECONNABORTED - connection_already_in_progress, //EALREADY - connection_refused, //ECONNREFUSED - connection_reset, //ECONNRESET - cross_device_link, //EXDEV - destination_address_required, //EDESTADDRREQ - device_or_resource_busy, //EBUSY - directory_not_empty, //ENOTEMPTY - executable_format_error, //ENOEXEC - file_exists, //EEXIST - file_too_large, //EFBIG - filename_too_long, //ENAMETOOLONG - function_not_supported, //ENOSYS - host_unreachable, //EHOSTUNREACH - identifier_removed, //EIDRM - illegal_byte_sequence, //EILSEQ - inappropriate_io_control_operation, //ENOTTY - interrupted, //EINTR - invalid_argument, //EINVAL - invalid_seek, //ESPIPE - io_error, //EIO - is_a_directory, //EISDIR - message_size, //EMSGSIZE - network_down, //ENETDOWN - network_reset, //ENETRESET - network_unreachable, //ENETUNREACH - no_buffer_space, //ENOBUFS - no_child_process, //ECHILD - no_link, //ENOLINK - no_lock_available, //ENOLCK - no_message_available, //ENODATA - no_message, //ENOMSG - no_protocol_option, //ENOPROTOOPT - no_space_on_device, //ENOSPC - no_stream_resources, //ENOSR - no_such_device_or_address, //ENXIO - no_such_device, //ENODEV - no_such_file_or_directory, //ENOENT - no_such_process, //ESRCH - not_a_directory, //ENOTDIR - not_a_socket, //ENOTSOCK - not_a_stream, //ENOSTR - not_connected, //ENOTCONN - not_enough_memory, //ENOMEM - not_supported, //ENOTSUP - operation_canceled, //ECANCELED - operation_in_progress, //EINPROGRESS - operation_not_permitted, //EPERM - operation_not_supported, //EOPNOTSUPP - operation_would_block, //EWOULDBLOCK - owner_dead, //EOWNERDEAD - permission_denied, //EACCES - protocol_error, //EPROTO - protocol_not_supported, //EPROTONOSUPPORT - read_only_file_system, //EROFS - resource_deadlock_would_occur, //EDEADLK - resource_unavailable_try_again, //EAGAIN - result_out_of_range, //ERANGE - state_not_recoverable, //ENOTRECOVERABLE - stream_timeout, //ETIME - text_file_busy, //ETXTBSY - timed_out, //ETIMEDOUT - too_many_files_open_in_system, //ENFILE - too_many_files_open, //EMFILE - too_many_links, //EMLINK - too_many_synbolic_link_levels, //ELOOP - value_too_large, //EOVERFLOW - wrong_protocol_type //EPROTOTYPE - }; +namespace errc { + enum errc_t + { + success = 0, + address_family_not_supported, //EAFNOSUPPORT + address_in_use, //EADDRINUSE + address_not_available, //EADDRNOTAVAIL + already_connected, //EISCONN + argument_list_too_long, //E2BIG + argument_out_of_domain, //EDOM + bad_address, //EFAULT + bad_file_descriptor, //EBADF + bad_message, //EBADMSG + broken_pipe, //EPIPE + connection_aborted, //ECONNABORTED + connection_already_in_progress, //EALREADY + connection_refused, //ECONNREFUSED + connection_reset, //ECONNRESET + cross_device_link, //EXDEV + destination_address_required, //EDESTADDRREQ + device_or_resource_busy, //EBUSY + directory_not_empty, //ENOTEMPTY + executable_format_error, //ENOEXEC + file_exists, //EEXIST + file_too_large, //EFBIG + filename_too_long, //ENAMETOOLONG + function_not_supported, //ENOSYS + host_unreachable, //EHOSTUNREACH + identifier_removed, //EIDRM + illegal_byte_sequence, //EILSEQ + inappropriate_io_control_operation, //ENOTTY + interrupted, //EINTR + invalid_argument, //EINVAL + invalid_seek, //ESPIPE + io_error, //EIO + is_a_directory, //EISDIR + message_size, //EMSGSIZE + network_down, //ENETDOWN + network_reset, //ENETRESET + network_unreachable, //ENETUNREACH + no_buffer_space, //ENOBUFS + no_child_process, //ECHILD + no_link, //ENOLINK + no_lock_available, //ENOLCK + no_message_available, //ENODATA + no_message, //ENOMSG + no_protocol_option, //ENOPROTOOPT + no_space_on_device, //ENOSPC + no_stream_resources, //ENOSR + no_such_device_or_address, //ENXIO + no_such_device, //ENODEV + no_such_file_or_directory, //ENOENT + no_such_process, //ESRCH + not_a_directory, //ENOTDIR + not_a_socket, //ENOTSOCK + not_a_stream, //ENOSTR + not_connected, //ENOTCONN + not_enough_memory, //ENOMEM + not_supported, //ENOTSUP + operation_canceled, //ECANCELED + operation_in_progress, //EINPROGRESS + operation_not_permitted, //EPERM + operation_not_supported, //EOPNOTSUPP + operation_would_block, //EWOULDBLOCK + owner_dead, //EOWNERDEAD + permission_denied, //EACCES + protocol_error, //EPROTO + protocol_not_supported, //EPROTONOSUPPORT + read_only_file_system, //EROFS + resource_deadlock_would_occur, //EDEADLK + resource_unavailable_try_again, //EAGAIN + result_out_of_range, //ERANGE + state_not_recoverable, //ENOTRECOVERABLE + stream_timeout, //ETIME + text_file_busy, //ETXTBSY + timed_out, //ETIMEDOUT + too_many_files_open_in_system, //ENFILE + too_many_files_open, //EMFILE + too_many_links, //EMLINK + too_many_synbolic_link_levels, //ELOOP + value_too_large, //EOVERFLOW + wrong_protocol_type //EPROTOTYPE + }; - } // namespace errc +} // namespace errc - template<> struct is_error_condition_enum - { static const bool value = true; }; +template<> struct is_error_condition_enum + { static const bool value = true; }; - constexpr error_code make_error_code( errc::errc_t e ) noexcept; - constexpr error_condition make_error_condition( errc::errc_t e ) noexcept; +constexpr error_code make_error_code( errc::errc_t e ) noexcept; +constexpr error_condition make_error_condition( errc::errc_t e ) noexcept; - } // namespace system +} // namespace system } // namespace boost ``` @@ -268,56 +268,56 @@ errors in addition to those defined in Boost.System. ``` namespace boost { - namespace system { +namespace system { - class error_category - { - public: // noncopyable +class error_category +{ +public: // noncopyable - error_category( error_category const & ) = delete; - error_category& operator=( error_category const & ) = delete; + error_category( error_category const & ) = delete; + error_category& operator=( error_category const & ) = delete; - protected: +protected: - ~error_category() = default; + ~error_category() = default; - constexpr error_category() noexcept; - explicit constexpr error_category( unsigned long long id ) noexcept; + constexpr error_category() noexcept; + explicit constexpr error_category( unsigned long long id ) noexcept; - public: +public: - virtual const char * name() const noexcept = 0; + virtual const char * name() const noexcept = 0; - virtual error_condition default_error_condition( int ev ) const noexcept; + virtual error_condition default_error_condition( int ev ) const noexcept; - virtual bool equivalent( int code, const error_condition & condition ) - const noexcept; - virtual bool equivalent( const error_code & code, int condition ) - const noexcept; + virtual bool equivalent( int code, const error_condition & condition ) + const noexcept; + virtual bool equivalent( const error_code & code, int condition ) + const noexcept; - virtual std::string message( int ev ) const = 0; - virtual char const * message( int ev, char * buffer, std::size_t len ) - const noexcept; + virtual std::string message( int ev ) const = 0; + virtual char const * message( int ev, char * buffer, std::size_t len ) + const noexcept; - virtual bool failed( int ev ) const noexcept; + virtual bool failed( int ev ) const noexcept; - friend constexpr bool operator==( const error_category & lhs, - const error_category & rhs ) noexcept; - friend constexpr bool operator!=( const error_category & lhs, - const error_category & rhs ) noexcept; + friend constexpr bool operator==( const error_category & lhs, + const error_category & rhs ) noexcept; + friend constexpr bool operator!=( const error_category & lhs, + const error_category & rhs ) noexcept; - friend constexpr bool operator< ( const error_category & lhs, - const error_category & rhs ) noexcept; + friend constexpr bool operator< ( const error_category & lhs, + const error_category & rhs ) noexcept; - operator std::error_category const & () const; + operator std::error_category const & () const; - private: +private: - unsigned long long id_; // exposition only + unsigned long long id_; // exposition only +}; - }; - } -} +} // namespace system +} // namespace boost ``` #### Constructors @@ -422,20 +422,24 @@ Example: :: ``` const char* my_category::message(int ev, char* buffer, size_t len) const noexcept { - switch(ev) - { - case 0: return "no error"; - case 1: return "voltage out of range"; - case 2: return "impedance mismatch"; - case 31: - case 32: - case 33: - std::snprintf(buffer, len, "component %d failure", ev-30); - return buffer; - default: - std::snprintf(buffer, len, "unknown error %d", ev); - return buffer; - } + switch(ev) + { + case 0: return "no error"; + case 1: return "voltage out of range"; + case 2: return "impedance mismatch"; + + case 31: + case 32: + case 33: + + std::snprintf(buffer, len, "component %d failure", ev-30); + return buffer; + + default: + + std::snprintf(buffer, len, "unknown error %d", ev); + return buffer; + } } ``` @@ -503,11 +507,11 @@ Returns: :: A reference to an `std::error_category` object corresponding ``` namespace boost { - namespace system { +namespace system { - constexpr const error_category & system_category() noexcept; +constexpr const error_category & system_category() noexcept; - } // namespace system +} // namespace system } // namespace boost ``` @@ -526,11 +530,11 @@ Returns: :: A reference to a predefined `error_category` object identifying ``` namespace boost { - namespace system { +namespace system { - constexpr const error_category & generic_category() noexcept; +constexpr const error_category & generic_category() noexcept; - } // namespace system +} // namespace system } // namespace boost ``` @@ -554,116 +558,116 @@ by exception. ``` namespace boost { - namespace system { +namespace system { - class error_code { - public: +class error_code { +public: - // constructors: + // constructors - constexpr error_code() noexcept; - constexpr error_code( int val, const error_category & cat ) noexcept; + constexpr error_code() noexcept; + constexpr error_code( int val, const error_category & cat ) noexcept; - error_code( int val, const error_category & cat, - boost::source_location const * loc ) noexcept; + error_code( int val, const error_category & cat, + boost::source_location const * loc ) noexcept; - template - constexpr error_code( ErrorCodeEnum e ) noexcept; + template + constexpr error_code( ErrorCodeEnum e ) noexcept; - error_code( std::error_code const& ec ) noexcept; + error_code( std::error_code const& ec ) noexcept; - // modifiers: + // modifiers - constexpr void assign( int val, const error_category & cat ) noexcept; + constexpr void assign( int val, const error_category & cat ) noexcept; - void assign( int val, const error_category & cat, - boost::source_location const * loc ) noexcept; + void assign( int val, const error_category & cat, + boost::source_location const * loc ) noexcept; - template - constexpr error_code & operator=( ErrorCodeEnum e ) noexcept; + template + constexpr error_code & operator=( ErrorCodeEnum e ) noexcept; - constexpr void clear() noexcept; + constexpr void clear() noexcept; - // observers: + // observers - constexpr int value() const noexcept; - constexpr const error_category & category() const noexcept; + constexpr int value() const noexcept; + constexpr const error_category & category() const noexcept; - error_condition default_error_condition() const noexcept; + error_condition default_error_condition() const noexcept; - std::string message() const; - char const * message( char * buffer, std::size_t len ) const noexcept; + std::string message() const; + char const * message( char * buffer, std::size_t len ) const noexcept; - constexpr bool failed() const noexcept; - constexpr explicit operator bool() const noexcept; + constexpr bool failed() const noexcept; + constexpr explicit operator bool() const noexcept; - bool has_location() const noexcept; - boost::source_location const & location() const noexcept; + bool has_location() const noexcept; + boost::source_location const & location() const noexcept; - // comparisons: + // comparisons - friend constexpr bool operator==( const error_code & lhs, - const error_code & rhs ) noexcept; + friend constexpr bool operator==( const error_code & lhs, + const error_code & rhs ) noexcept; - friend constexpr bool operator!=( const error_code & lhs, - const error_code & rhs ) noexcept; + friend constexpr bool operator!=( const error_code & lhs, + const error_code & rhs ) noexcept; - friend constexpr bool operator<( const error_code & lhs, - const error_code & rhs ) noexcept; + friend constexpr bool operator<( const error_code & lhs, + const error_code & rhs ) noexcept; - friend bool operator==( const error_code & code, - const error_condition & condition ) noexcept; - friend bool operator==( const error_condition & condition, - const error_code & code ) noexcept; + friend bool operator==( const error_code & code, + const error_condition & condition ) noexcept; + friend bool operator==( const error_condition & condition, + const error_code & code ) noexcept; - friend bool operator!=( const error_code & code, - const error_condition & condition ) noexcept; - friend bool operator!=( const error_condition & condition, - const error_code & code ) noexcept; + friend bool operator!=( const error_code & code, + const error_condition & condition ) noexcept; + friend bool operator!=( const error_condition & condition, + const error_code & code ) noexcept; - friend bool operator==( const error_code & lhs, - const std::error_code & rhs ) noexcept; - friend bool operator==( const std::error_code & lhs, - const error_code & rhs ) noexcept; + friend bool operator==( const error_code & lhs, + const std::error_code & rhs ) noexcept; + friend bool operator==( const std::error_code & lhs, + const error_code & rhs ) noexcept; - friend bool operator!=( const error_code & lhs, - const std::error_code & rhs ) noexcept; - friend bool operator!=( const std::error_code & lhs, - const error_code & rhs ) noexcept; + friend bool operator!=( const error_code & lhs, + const std::error_code & rhs ) noexcept; + friend bool operator!=( const std::error_code & lhs, + const error_code & rhs ) noexcept; - template + template friend constexpr bool operator==( const error_code & lhs, E rhs ) noexcept; - template + template friend constexpr bool operator==( E lhs, const error_code & rhs ) noexcept; - template + template friend constexpr bool operator!=( const error_code & lhs, E rhs ) noexcept; - template + template friend constexpr bool operator!=( E lhs, const error_code & rhs ) noexcept; - // conversions: + // conversions - operator std::error_code() const; - operator std::error_code(); - template operator T& (); // only when T=std::error_code + operator std::error_code() const; + operator std::error_code(); + template operator T& (); // only when T=std::error_code - // to_string + // to_string - std::string to_string() const; + std::string to_string() const; - // stream insertion: + // stream insertion - template - std::basic_ostream& - operator<<( basic_ostream& os, const error_code & ec ); - }; + template + friend std::basic_ostream& + operator<<( basic_ostream& os, const error_code & ec ); +}; - // non-member functions +// non-member functions - std::size_t hash_value( const error_code & ec ); +std::size_t hash_value( const error_code & ec ); - } -} +} // namespace system +} // namespace boost ``` #### Constructors @@ -1034,72 +1038,73 @@ Returns: :: If `ec` wraps a `std::error_code` object `e2`, `std::hash - constexpr error_condition( ErrorConditionEnum e ) noexcept; + template + constexpr error_condition( ErrorConditionEnum e ) noexcept; - // modifiers: + // modifiers - constexpr void assign( int val, const error_category & cat ) noexcept; + constexpr void assign( int val, const error_category & cat ) noexcept; - template - constexpr error_condition & operator=( ErrorConditionEnum e ) noexcept; + template + constexpr error_condition & operator=( ErrorConditionEnum e ) noexcept; - constexpr void clear() noexcept; + constexpr void clear() noexcept; - // observers: + // observers - constexpr int value() const noexcept; - constexpr const error_category & category() const noexcept; + constexpr int value() const noexcept; + constexpr const error_category & category() const noexcept; - std::string message() const; - char const * message( char * buffer, std::size_t len ) const noexcept; + std::string message() const; + char const * message( char * buffer, std::size_t len ) const noexcept; - constexpr bool failed() const noexcept; - constexpr explicit operator bool() const noexcept; + constexpr bool failed() const noexcept; + constexpr explicit operator bool() const noexcept; - // comparisons: + // comparisons - friend constexpr bool operator==( const error_condition & lhs, - const error_condition & rhs ) noexcept; + friend constexpr bool operator==( const error_condition & lhs, + const error_condition & rhs ) noexcept; - friend constexpr bool operator!=( const error_condition & lhs, - const error_condition & rhs ) noexcept; + friend constexpr bool operator!=( const error_condition & lhs, + const error_condition & rhs ) noexcept; - friend constexpr bool operator<( const error_condition & lhs, - const error_condition & rhs ) noexcept; + friend constexpr bool operator<( const error_condition & lhs, + const error_condition & rhs ) noexcept; - friend bool operator==( const std::error_code & code, - const error_condition & condition ) noexcept; - friend bool operator==( const error_condition & condition, - const std::error_code & code ) noexcept; + friend bool operator==( const std::error_code & code, + const error_condition & condition ) noexcept; + friend bool operator==( const error_condition & condition, + const std::error_code & code ) noexcept; - friend bool operator!=( const std::error_code & code, - const error_condition & condition ) noexcept; - friend bool operator!=( const error_condition & condition, - const std::error_code & code ) noexcept; + friend bool operator!=( const std::error_code & code, + const error_condition & condition ) noexcept; + friend bool operator!=( const error_condition & condition, + const std::error_code & code ) noexcept; - // conversions: + // conversions - operator std::error_condition() const; + operator std::error_condition() const; - // stream insertion: + // stream insertion - template - std::basic_ostream& - operator<<( basic_ostream& os, const error_condition & en ); - }; - } -} + template + friend std::basic_ostream& + operator<<( basic_ostream& os, const error_condition & en ); +}; + +} // namespace system +} // namespace boost ``` #### Constructors @@ -1295,7 +1300,7 @@ Returns: :: ## -### Class system_error +### system_error The class `system_error` describes an exception object used to report errors that have an associated `error_code`. Such errors @@ -1303,29 +1308,29 @@ typically originate from operating system or other low-level application program interfaces. ``` -namespace boost +namespace boost { +namespace system { + +class system_error: public std::runtime_error { - namespace system - { - class system_error: public std::runtime_error - { - public: +public: - explicit system_error( error_code ec ); - system_error( error_code ec, const char * what_arg ); - system_error( error_code ec, const std::string & what_arg ); + explicit system_error( error_code ec ); + system_error( error_code ec, const char * what_arg ); + system_error( error_code ec, const std::string & what_arg ); - system_error( int ev, const error_category & ecat ); - system_error( int ev, const error_category & ecat, - const char * what_arg ); - system_error( int ev, const error_category & ecat, - const std::string & what_arg ); + system_error( int ev, const error_category & ecat ); + system_error( int ev, const error_category & ecat, + const char * what_arg ); + system_error( int ev, const error_category & ecat, + const std::string & what_arg ); - error_code code() const noexcept; - const char * what() const noexcept; - }; - } -} + error_code code() const noexcept; + const char * what() const noexcept; +}; + +} // namespace system +} // namespace boost ``` #### Constructors