|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r81808 - in trunk: boost/asio/impl boost/system boost/thread libs/filesystem/src libs/system/src libs/system/test libs/thread/src
From: vicente.botet_at_[hidden]
Date: 2012-12-09 09:47:40
Author: viboes
Date: 2012-12-09 09:47:39 EST (Sun, 09 Dec 2012)
New Revision: 81808
URL: http://svn.boost.org/trac/boost/changeset/81808
Log:
System/FileSystem/Asio/Thread: ref #7278 Added noexcept to Boost.System to conform with C++11
Text files modified:
trunk/boost/asio/impl/error.ipp | 6
trunk/boost/system/error_code.hpp | 134 +++++++++++++++++++++------------------
trunk/boost/system/system_error.hpp | 6 +
trunk/boost/thread/future.hpp | 4
trunk/libs/filesystem/src/codecvt_error_category.cpp | 4
trunk/libs/system/src/error_code.cpp | 43 +++++++-----
trunk/libs/system/test/error_code_user_test.cpp | 16 ++--
trunk/libs/thread/src/future.cpp | 4
8 files changed, 118 insertions(+), 99 deletions(-)
Modified: trunk/boost/asio/impl/error.ipp
==============================================================================
--- trunk/boost/asio/impl/error.ipp (original)
+++ trunk/boost/asio/impl/error.ipp 2012-12-09 09:47:39 EST (Sun, 09 Dec 2012)
@@ -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";
}
Modified: trunk/boost/system/error_code.hpp
==============================================================================
--- trunk/boost/system/error_code.hpp (original)
+++ trunk/boost/system/error_code.hpp 2012-12-09 09:47:39 EST (Sun, 09 Dec 2012)
@@ -23,7 +23,7 @@
#include <functional>
// TODO: undef these macros if not already defined
-#include <boost/cerrno.hpp>
+#include <boost/cerrno.hpp>
#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 <boost/config/abi_prefix.hpp> // 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;
-
- 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
+ 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 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<const error_category*>()( 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 <class ErrorConditionEnum>
error_condition(ErrorConditionEnum e,
- typename boost::enable_if<is_error_condition_enum<ErrorConditionEnum> >::type* = 0)
+ typename boost::enable_if<is_error_condition_enum<ErrorConditionEnum> >::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 ErrorConditionEnum>
typename boost::enable_if<is_error_condition_enum<ErrorConditionEnum>, 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 <class ErrorCodeEnum>
error_code(ErrorCodeEnum e,
- typename boost::enable_if<is_error_code_enum<ErrorCodeEnum> >::type* = 0)
+ typename boost::enable_if<is_error_code_enum<ErrorCodeEnum> >::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 ErrorCodeEnum>
typename boost::enable_if<is_error_code_enum<ErrorCodeEnum>, 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 <class charT, class traits>
@@ -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;
}
Modified: trunk/boost/system/system_error.hpp
==============================================================================
--- trunk/boost/system/system_error.hpp (original)
+++ trunk/boost/system/system_error.hpp 2012-12-09 09:47:39 EST (Sun, 09 Dec 2012)
@@ -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();
}
Modified: trunk/boost/thread/future.hpp
==============================================================================
--- trunk/boost/thread/future.hpp (original)
+++ trunk/boost/thread/future.hpp 2012-12-09 09:47:39 EST (Sun, 09 Dec 2012)
@@ -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<int>(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<int>(e), future_category());
}
Modified: trunk/libs/filesystem/src/codecvt_error_category.cpp
==============================================================================
--- trunk/libs/filesystem/src/codecvt_error_category.cpp (original)
+++ trunk/libs/filesystem/src/codecvt_error_category.cpp 2012-12-09 09:47:39 EST (Sun, 09 Dec 2012)
@@ -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";
}
Modified: trunk/libs/system/src/error_code.cpp
==============================================================================
--- trunk/libs/system/src/error_code.cpp (original)
+++ trunk/libs/system/src/error_code.cpp 2012-12-09 09:47:39 EST (Sun, 09 Dec 2012)
@@ -22,9 +22,6 @@
#include <cstdlib>
#include <cassert>
-using namespace boost::system;
-using namespace boost::system::errc;
-
#include <cstring> // 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;
Modified: trunk/libs/system/test/error_code_user_test.cpp
==============================================================================
--- trunk/libs/system/test/error_code_user_test.cpp (original)
+++ trunk/libs/system/test/error_code_user_test.cpp 2012-12-09 09:47:39 EST (Sun, 09 Dec 2012)
@@ -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;
Modified: trunk/libs/thread/src/future.cpp
==============================================================================
--- trunk/libs/thread/src/future.cpp (original)
+++ trunk/libs/thread/src/future.cpp 2012-12-09 09:47:39 EST (Sun, 09 Dec 2012)
@@ -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";
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk