From 7cc96d23ec277cd57048e58c3c4f23424738c9fc Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Sat, 3 May 2008 19:51:41 +0000 Subject: [PATCH] Improved compatibility with various compilers. [SVN r45087] --- .../boost/exception/detail/cloning_base.hpp | 5 +- .../boost/exception/detail/counted_base.hpp | 5 +- include/boost/exception/exception.hpp | 76 ++++++++++++------- include/boost/exception/info.hpp | 3 +- 4 files changed, 57 insertions(+), 32 deletions(-) diff --git a/include/boost/exception/detail/cloning_base.hpp b/include/boost/exception/detail/cloning_base.hpp index 1631951..86dc400 100644 --- a/include/boost/exception/detail/cloning_base.hpp +++ b/include/boost/exception/detail/cloning_base.hpp @@ -6,6 +6,8 @@ #ifndef UUID_F7D5662CCB0F11DCA353CAC656D89593 #define UUID_F7D5662CCB0F11DCA353CAC656D89593 +#include + namespace boost { @@ -23,9 +25,8 @@ boost protected: -#ifdef __GNUC__ +#if BOOST_WORKAROUND( __GNUC__, BOOST_TESTED_AT(4) ) virtual //Disable bogus GCC warning. -//Would someone at GCC finally get the protected, non-virtual destructor approach? #endif ~cloning_base() throw() { diff --git a/include/boost/exception/detail/counted_base.hpp b/include/boost/exception/detail/counted_base.hpp index 0dca267..75f6375 100644 --- a/include/boost/exception/detail/counted_base.hpp +++ b/include/boost/exception/detail/counted_base.hpp @@ -6,6 +6,8 @@ #ifndef UUID_DBA0D90C930911DCBA7B675A56D89593 #define UUID_DBA0D90C930911DCBA7B675A56D89593 +#include + namespace boost { @@ -34,9 +36,8 @@ boost protected: -#ifdef __GNUC__ +#if BOOST_WORKAROUND( __GNUC__, BOOST_TESTED_AT(4) ) virtual //Disable bogus GCC warning. -//Would someone at GCC finally get the protected, non-virtual destructor approach? #endif ~counted_base() throw() { diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 2180d50..e57d865 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -6,6 +6,8 @@ #ifndef UUID_274DA366004E11DCB1DDFE2E56D89593 #define UUID_274DA366004E11DCB1DDFE2E56D89593 +#include +#include #include #include #include @@ -45,8 +47,46 @@ boost { public: - virtual ~exception() throw()=0; - virtual char const * what() const throw(); + virtual + char const * + what() const throw() + { + if( data_ ) + try + { + char const * w = data_->what(typeid(*this)); + BOOST_ASSERT(0!=w); + return w; + } + catch(...) + { + } + return typeid(*this).name(); + } + + protected: + + exception() + { + } + + exception( exception const & e ): + data_(e.data_) + { + } + +#if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1500) ) + //Force class exception to be abstract. + //Otherwise, MSVC bug allows throw exception(), even though the copy constructor is protected. + virtual ~exception() throw()=0; +#else +#if BOOST_WORKAROUND( __GNUC__, BOOST_TESTED_AT(4) ) + virtual //Disable bogus GCC warning. +#endif + ~exception() throw() + { + } +#endif private: @@ -62,29 +102,13 @@ boost intrusive_ptr mutable data_; }; - inline - exception:: - ~exception() throw() - { - } - - inline - char const * - exception:: - what() const throw() - { - if( data_ ) - try - { - char const * w = data_->what(typeid(*this)); - BOOST_ASSERT(0!=w); - return w; - } - catch(...) - { - } - return typeid(*this).name(); - } - } +#if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1500) ) //See above. + inline + exception:: + ~exception() throw() + { + } +#endif + } #endif diff --git a/include/boost/exception/info.hpp b/include/boost/exception/info.hpp index 7a9d146..2ce8ba8 100644 --- a/include/boost/exception/info.hpp +++ b/include/boost/exception/info.hpp @@ -39,9 +39,8 @@ boost protected: -#ifdef __GNUC__ +#if BOOST_WORKAROUND( __GNUC__, BOOST_TESTED_AT(4) ) virtual //Disable bogus GCC warning. -//Would someone at GCC finally get the protected, non-virtual destructor approach? #endif ~error_info_base() {