
Le 27/08/12 19:33, Beman Dawes a écrit :
Ticket #7278 asks that Boost.System add C++11 noexcept support. A reasonable request, and I implemented it this morning by adding BOOST_NOEXCEPT at the appropriate places specified in the standard.
But there is a problem. noexcept is viral, so any classes that inherit from a class that uses noexcept must be changed to also use no except.
An example: Boost.Filesystem has this class:
class codecvt_error_cat : public boost::system::error_category { public: codecvt_error_cat(){} const char* name() const {return "codecvt";} std::string message(int ev) const; };
Compiling with GCC 4.7 -std=c++0x results in this error:
..\..\../boost/system/error_code.hpp:187:32: error: overriding 'virtual const char* boost::system::error_category::name() const noexcept (true)'
To fix it, the filesystem class has to be changed:
class codecvt_error_cat : public boost::system::error_category { public: codecvt_error_cat(){} const char* name() const BOOST_NOEXCEPT {return "codecvt";} std::string message(int ev) const; };
I've held off committing the Boost.System changes to trunk until we've had a chance to discuss how to approach this potential break to an unknown number of Boost and user libraries.
Ideas?
Hrr, this is really annoying. I have introduced a lot of BOOST_NOEXCEPT in Boost.Chrono and Boost.Thread without thinking that I was changing the interface. Apologies to any one these changes could break their code. One possibility could be to use BOOST_SYSTEM_NOEXCEPT instead. Boost.System could define it depending on the Boost.System version as #if ! defined BOOST_SYSTEM_VERSION #define BOOST_SYSTEM_VERSION 1 #endif #if BOOST_SYSTEM_VERSION < 2 #define BOOST_SYSTEM_NOEXCEPT #else #define BOOST_SYSTEM_NOEXCEPT #endif and let the time to the others libraries to move to the new version. Once all the dependent Boost libraries have made the change, Boost.System could increase the version #if ! defined BOOST_SYSTEM_VERSION #define BOOST_SYSTEM_VERSION 2 #endif The dependent user could always force the Boost.System version. HTH, Vicente