Index: boost/asio/impl/error.ipp =================================================================== --- boost/asio/impl/error.ipp (revision 81784) +++ boost/asio/impl/error.ipp (working copy) @@ -31,7 +31,7 @@ class netdb_category : public boost::system::error_category { public: - const char* name() const + const char* name() const BOOST_SYSTEM_NOEXCEPT { return "asio.netdb"; } @@ -63,7 +63,7 @@ class addrinfo_category : public boost::system::error_category { public: - const char* name() const + const char* name() const BOOST_SYSTEM_NOEXCEPT { return "asio.addrinfo"; } @@ -93,7 +93,7 @@ class misc_category : public boost::system::error_category { public: - const char* name() const + const char* name() const BOOST_SYSTEM_NOEXCEPT { return "asio.misc"; } Index: boost/thread/future.hpp =================================================================== --- boost/thread/future.hpp (revision 81784) +++ boost/thread/future.hpp (working copy) @@ -113,14 +113,14 @@ { inline error_code - make_error_code(future_errc e) //BOOST_NOEXCEPT + make_error_code(future_errc e) BOOST_SYSTEM_NOEXCEPT { return error_code(underlying_cast(e), boost::future_category()); } inline error_condition - make_error_condition(future_errc e) //BOOST_NOEXCEPT + make_error_condition(future_errc e) BOOST_SYSTEM_NOEXCEPT { return error_condition(underlying_cast(e), future_category()); } Index: libs/thread/src/future.cpp =================================================================== --- libs/thread/src/future.cpp (revision 81784) +++ libs/thread/src/future.cpp (working copy) @@ -19,12 +19,12 @@ public boost::system::error_category { public: - virtual const char* name() const; //BOOST_NOEXCEPT; + virtual const char* name() const BOOST_SYSTEM_NOEXCEPT; virtual std::string message(int ev) const; }; const char* - future_error_category::name() const //BOOST_NOEXCEPT + future_error_category::name() const BOOST_SYSTEM_NOEXCEPT { return "future"; } Index: libs/filesystem/src/codecvt_error_category.cpp =================================================================== --- libs/filesystem/src/codecvt_error_category.cpp (revision 81784) +++ libs/filesystem/src/codecvt_error_category.cpp (working copy) @@ -35,11 +35,11 @@ { public: codecvt_error_cat(){} - const char* name() const; + const char* name() const BOOST_SYSTEM_NOEXCEPT; std::string message(int ev) const; }; - const char* codecvt_error_cat::name() const + const char* codecvt_error_cat::name() const BOOST_SYSTEM_NOEXCEPT { return "codecvt"; } Index: boost/system/system_error.hpp =================================================================== --- boost/system/system_error.hpp (revision 81784) +++ boost/system/system_error.hpp (working copy) @@ -21,7 +21,7 @@ class BOOST_SYMBOL_VISIBLE system_error : public std::runtime_error // BOOST_SYMBOL_VISIBLE is needed by GCC to ensure system_error thrown from a shared - // library can be caught. See svn.boost.org/trac/boost/ticket/3697 + // library can be caught. See svn.boost.org/trac/boost/ticket/3697 { public: system_error( error_code ec ) @@ -61,13 +61,17 @@ { if ( m_what.empty() ) { +#ifndef BOOST_NO_EXCEPTIONS try +#endif { m_what = this->std::runtime_error::what(); if ( !m_what.empty() ) m_what += ": "; m_what += m_error_code.message(); } +#ifndef BOOST_NO_EXCEPTIONS catch (...) { return std::runtime_error::what(); } +#endif } return m_what.c_str(); } Index: boost/system/error_code.hpp =================================================================== --- boost/system/error_code.hpp (revision 81784) +++ boost/system/error_code.hpp (working copy) @@ -23,7 +23,7 @@ #include // TODO: undef these macros if not already defined -#include +#include #if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API) # error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined @@ -31,6 +31,10 @@ #include // must be the last #include +#ifndef BOOST_SYSTEM_NOEXCEPT +#define BOOST_SYSTEM_NOEXCEPT BOOST_NOEXCEPT +#endif + namespace boost { namespace system @@ -184,17 +188,17 @@ public: virtual ~error_category(){} - virtual const char * name() const = 0; + virtual const char * name() const BOOST_SYSTEM_NOEXCEPT = 0; virtual std::string message( int ev ) const = 0; - virtual error_condition default_error_condition( int ev ) const; - virtual bool equivalent( int code, - const error_condition & condition ) const; - virtual bool equivalent( const error_code & code, - int condition ) const; + inline virtual error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT; + inline virtual bool equivalent( int code, + const error_condition & condition ) const BOOST_SYSTEM_NOEXCEPT; + inline virtual bool equivalent( const error_code & code, + int condition ) const BOOST_SYSTEM_NOEXCEPT; - bool operator==(const error_category & rhs) const { return this == &rhs; } - bool operator!=(const error_category & rhs) const { return this != &rhs; } - bool operator<( const error_category & rhs ) const + bool operator==(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT { return this == &rhs; } + bool operator!=(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT { return this != &rhs; } + bool operator<( const error_category & rhs ) const BOOST_SYSTEM_NOEXCEPT { return std::less()( this, &rhs ); } @@ -202,9 +206,13 @@ // predefined error categories -----------------------------------------// - BOOST_SYSTEM_DECL const error_category & system_category(); - BOOST_SYSTEM_DECL const error_category & generic_category(); - +# ifdef BOOST_ERROR_CODE_HEADER_ONLY + inline const error_category & system_category() BOOST_SYSTEM_NOEXCEPT; + inline const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT; +#else + BOOST_SYSTEM_DECL const error_category & system_category() BOOST_SYSTEM_NOEXCEPT; + BOOST_SYSTEM_DECL const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT; +#endif // deprecated synonyms --------------------------------------------------// # ifndef BOOST_SYSTEM_NO_DEPRECATED @@ -225,52 +233,52 @@ public: // constructors: - error_condition() : m_val(0), m_cat(&generic_category()) {} - error_condition( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {} + error_condition() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&generic_category()) {} + error_condition( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT : m_val(val), m_cat(&cat) {} template error_condition(ErrorConditionEnum e, - typename boost::enable_if >::type* = 0) + typename boost::enable_if >::type* = 0) BOOST_SYSTEM_NOEXCEPT { *this = make_error_condition(e); } // modifiers: - void assign( int val, const error_category & cat ) - { + void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT + { m_val = val; m_cat = &cat; } - + template typename boost::enable_if, error_condition>::type & - operator=( ErrorConditionEnum val ) - { + operator=( ErrorConditionEnum val ) BOOST_SYSTEM_NOEXCEPT + { *this = make_error_condition(val); return *this; } - void clear() + void clear() BOOST_SYSTEM_NOEXCEPT { m_val = 0; m_cat = &generic_category(); } // observers: - int value() const { return m_val; } - const error_category & category() const { return *m_cat; } + int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; } + const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; } std::string message() const { return m_cat->message(value()); } typedef void (*unspecified_bool_type)(); static void unspecified_bool_true() {} - operator unspecified_bool_type() const // true if error - { + operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error + { return m_val == 0 ? 0 : unspecified_bool_true; } - bool operator!() const // true if no error + bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error { return m_val == 0; } @@ -279,13 +287,13 @@ // the more symmetrical non-member syntax allows enum // conversions work for both rhs and lhs. inline friend bool operator==( const error_condition & lhs, - const error_condition & rhs ) + const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT { return lhs.m_cat == rhs.m_cat && lhs.m_val == rhs.m_val; - } + } inline friend bool operator<( const error_condition & lhs, - const error_condition & rhs ) + const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT // the more symmetrical non-member syntax allows enum // conversions work for both rhs and lhs. { @@ -312,59 +320,59 @@ public: // constructors: - error_code() : m_val(0), m_cat(&system_category()) {} - error_code( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {} + error_code() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&system_category()) {} + error_code( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT : m_val(val), m_cat(&cat) {} template error_code(ErrorCodeEnum e, - typename boost::enable_if >::type* = 0) + typename boost::enable_if >::type* = 0) BOOST_SYSTEM_NOEXCEPT { *this = make_error_code(e); } // modifiers: - void assign( int val, const error_category & cat ) - { + void assign( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT + { m_val = val; m_cat = &cat; } - + template typename boost::enable_if, error_code>::type & - operator=( ErrorCodeEnum val ) - { + operator=( ErrorCodeEnum val ) BOOST_SYSTEM_NOEXCEPT + { *this = make_error_code(val); return *this; } - void clear() + void clear() BOOST_SYSTEM_NOEXCEPT { m_val = 0; m_cat = &system_category(); } // observers: - int value() const { return m_val; } - const error_category & category() const { return *m_cat; } - error_condition default_error_condition() const { return m_cat->default_error_condition(value()); } + int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; } + const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; } + error_condition default_error_condition() const BOOST_SYSTEM_NOEXCEPT { return m_cat->default_error_condition(value()); } std::string message() const { return m_cat->message(value()); } typedef void (*unspecified_bool_type)(); static void unspecified_bool_true() {} - operator unspecified_bool_type() const // true if error - { + operator unspecified_bool_type() const BOOST_SYSTEM_NOEXCEPT // true if error + { return m_val == 0 ? 0 : unspecified_bool_true; } - bool operator!() const // true if no error + bool operator!() const BOOST_SYSTEM_NOEXCEPT // true if no error { return m_val == 0; } // relationals: inline friend bool operator==( const error_code & lhs, - const error_code & rhs ) + const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT // the more symmetrical non-member syntax allows enum // conversions work for both rhs and lhs. { @@ -372,14 +380,14 @@ } inline friend bool operator<( const error_code & lhs, - const error_code & rhs ) + const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT // the more symmetrical non-member syntax allows enum // conversions work for both rhs and lhs. { return lhs.m_cat < rhs.m_cat || (lhs.m_cat == rhs.m_cat && lhs.m_val < rhs.m_val); } - + private: int m_val; const error_category * m_cat; @@ -426,31 +434,31 @@ } inline bool operator==( const error_code & code, - const error_condition & condition ) + const error_condition & condition ) BOOST_SYSTEM_NOEXCEPT { return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() ); } - + inline bool operator!=( const error_code & lhs, - const error_condition & rhs ) + const error_condition & rhs ) BOOST_SYSTEM_NOEXCEPT { return !(lhs == rhs); } - + inline bool operator==( const error_condition & condition, - const error_code & code ) + const error_code & code ) BOOST_SYSTEM_NOEXCEPT { return condition.category().equivalent( code, condition.value() ) || code.category().equivalent( code.value(), condition ); } - + inline bool operator!=( const error_condition & lhs, - const error_code & rhs ) + const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT { return !(lhs == rhs); } - + // TODO: both of these may move elsewhere, but the LWG hasn't spoken yet. template @@ -482,19 +490,19 @@ // error_category default implementation -------------------------------// - inline error_condition error_category::default_error_condition( int ev ) const - { + error_condition error_category::default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT + { return error_condition( ev, *this ); } - inline bool error_category::equivalent( int code, - const error_condition & condition ) const + bool error_category::equivalent( int code, + const error_condition & condition ) const BOOST_SYSTEM_NOEXCEPT { return default_error_condition( code ) == condition; } - inline bool error_category::equivalent( const error_code & code, - int condition ) const + bool error_category::equivalent( const error_code & code, + int condition ) const BOOST_SYSTEM_NOEXCEPT { return *this == code.category() && code.value() == condition; } Index: libs/system/test/error_code_user_test.cpp =================================================================== --- libs/system/test/error_code_user_test.cpp (revision 81784) +++ libs/system/test/error_code_user_test.cpp (working copy) @@ -75,7 +75,7 @@ namespace lib3 { // lib3 has its own error_category: - const boost::system::error_category & get_lib3_error_category(); + const boost::system::error_category & get_lib3_error_category() BOOST_SYSTEM_NOEXCEPT; const boost::system::error_category & lib3_error_category = get_lib3_error_category(); enum error @@ -112,12 +112,12 @@ public: lib3_error_category_imp() : boost::system::error_category() { } - const char * name() const + const char * name() const BOOST_SYSTEM_NOEXCEPT { return "lib3"; } - boost::system::error_condition default_error_condition( int ev ) const + boost::system::error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT { return ev == boo_boo ? boost::system::error_condition( boost::system::errc::io_error, @@ -135,7 +135,7 @@ }; - const boost::system::error_category & get_lib3_error_category() + const boost::system::error_category & get_lib3_error_category() BOOST_SYSTEM_NOEXCEPT { static const lib3_error_category_imp l3ecat; return l3ecat; @@ -156,7 +156,7 @@ namespace lib4 { // lib4 has its own error_category: - const boost::system::error_category & get_lib4_error_category(); + const boost::system::error_category & get_lib4_error_category() BOOST_SYSTEM_NOEXCEPT; const boost::system::error_category & lib4_error_category = get_lib4_error_category(); extern const boost::system::error_code boo_boo; @@ -174,12 +174,12 @@ public: lib4_error_category_imp() : boost::system::error_category() { } - const char * name() const + const char * name() const BOOST_SYSTEM_NOEXCEPT { return "lib4"; } - boost::system::error_condition default_error_condition( int ev ) const + boost::system::error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT { return ev == boo_boo.value() ? boost::system::error_condition( boost::system::errc::io_error, @@ -195,7 +195,7 @@ } }; - const boost::system::error_category & get_lib4_error_category() + const boost::system::error_category & get_lib4_error_category() BOOST_SYSTEM_NOEXCEPT { static const lib4_error_category_imp l4ecat; return l4ecat; Index: libs/system/src/error_code.cpp =================================================================== --- libs/system/src/error_code.cpp (revision 81784) +++ libs/system/src/error_code.cpp (working copy) @@ -22,9 +22,6 @@ #include #include -using namespace boost::system; -using namespace boost::system::errc; - #include // for strerror/strerror_r # if defined( BOOST_WINDOWS_API ) @@ -36,19 +33,21 @@ # endif //----------------------------------------------------------------------------// +namespace boost +{ + namespace system + { namespace { -#if defined(__PGI) - using boost::system::errc::invalid_argument; -#endif + // standard error categories ---------------------------------------------// class generic_error_category : public error_category { public: generic_error_category(){} - const char * name() const; + const char * name() const BOOST_SYSTEM_NOEXCEPT; std::string message( int ev ) const; }; @@ -56,20 +55,25 @@ { public: system_error_category(){} - const char * name() const; + const char * name() const BOOST_SYSTEM_NOEXCEPT; std::string message( int ev ) const; - error_condition default_error_condition( int ev ) const; + error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT; }; // generic_error_category implementation ---------------------------------// - const char * generic_error_category::name() const + const char * generic_error_category::name() const BOOST_SYSTEM_NOEXCEPT { return "generic"; } std::string generic_error_category::message( int ev ) const { + using namespace boost::system::errc; +#if defined(__PGI) + using boost::system::errc::invalid_argument; +#endif + static std::string unknown_err( "Unknown error" ); // strerror_r is preferred because it is always thread safe, // however, we fallback to strerror in certain cases because: @@ -133,7 +137,9 @@ } } std::string msg; +# ifndef BOOST_NO_EXCEPTIONS try +# endif { msg = ( ( result == invalid_argument ) ? "Unknown error" : bp ); } @@ -154,13 +160,18 @@ } // system_error_category implementation --------------------------------// - const char * system_error_category::name() const + const char * system_error_category::name() const BOOST_SYSTEM_NOEXCEPT { return "system"; } - error_condition system_error_category::default_error_condition( int ev ) const + error_condition system_error_category::default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT { + using namespace boost::system::errc; +#if defined(__PGI) + using boost::system::errc::invalid_argument; +#endif + switch ( ev ) { case 0: return make_error_condition( success ); @@ -401,10 +412,6 @@ } // unnamed namespace -namespace boost -{ - namespace system - { # ifndef BOOST_SYSTEM_NO_DEPRECATED BOOST_SYSTEM_DECL error_code throws; // "throw on error" special error_code; @@ -414,13 +421,13 @@ // address for comparison purposes # endif - BOOST_SYSTEM_DECL const error_category & system_category() + BOOST_SYSTEM_DECL const error_category & system_category() BOOST_SYSTEM_NOEXCEPT { static const system_error_category system_category_const; return system_category_const; } - BOOST_SYSTEM_DECL const error_category & generic_category() + BOOST_SYSTEM_DECL const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT { static const generic_error_category generic_category_const; return generic_category_const;