Boost logo

Boost-Commit :

From: emil_at_[hidden]
Date: 2008-05-03 15:51:42


Author: emildotchevski
Date: 2008-05-03 15:51:41 EDT (Sat, 03 May 2008)
New Revision: 45087
URL: http://svn.boost.org/trac/boost/changeset/45087

Log:
Improved compatibility with various compilers.
Text files modified:
   trunk/boost/exception/detail/cloning_base.hpp | 5 +-
   trunk/boost/exception/detail/counted_base.hpp | 5 +-
   trunk/boost/exception/exception.hpp | 76 ++++++++++++++++++++++++++-------------
   trunk/boost/exception/info.hpp | 3 -
   4 files changed, 57 insertions(+), 32 deletions(-)

Modified: trunk/boost/exception/detail/cloning_base.hpp
==============================================================================
--- trunk/boost/exception/detail/cloning_base.hpp (original)
+++ trunk/boost/exception/detail/cloning_base.hpp 2008-05-03 15:51:41 EDT (Sat, 03 May 2008)
@@ -6,6 +6,8 @@
 #ifndef UUID_F7D5662CCB0F11DCA353CAC656D89593
 #define UUID_F7D5662CCB0F11DCA353CAC656D89593
 
+#include <boost/detail/workaround.hpp>
+
 namespace
 boost
     {
@@ -23,9 +25,8 @@
 
             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()
                 {

Modified: trunk/boost/exception/detail/counted_base.hpp
==============================================================================
--- trunk/boost/exception/detail/counted_base.hpp (original)
+++ trunk/boost/exception/detail/counted_base.hpp 2008-05-03 15:51:41 EDT (Sat, 03 May 2008)
@@ -6,6 +6,8 @@
 #ifndef UUID_DBA0D90C930911DCBA7B675A56D89593
 #define UUID_DBA0D90C930911DCBA7B675A56D89593
 
+#include <boost/detail/workaround.hpp>
+
 namespace
 boost
     {
@@ -34,9 +36,8 @@
 
             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()
                 {

Modified: trunk/boost/exception/exception.hpp
==============================================================================
--- trunk/boost/exception/exception.hpp (original)
+++ trunk/boost/exception/exception.hpp 2008-05-03 15:51:41 EDT (Sat, 03 May 2008)
@@ -6,6 +6,8 @@
 #ifndef UUID_274DA366004E11DCB1DDFE2E56D89593
 #define UUID_274DA366004E11DCB1DDFE2E56D89593
 
+#include <boost/config.hpp>
+#include <boost/detail/workaround.hpp>
 #include <boost/exception/detail/counted_base.hpp>
 #include <boost/intrusive_ptr.hpp>
 #include <typeinfo>
@@ -45,8 +47,46 @@
         {
         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 @@
         intrusive_ptr<exception_detail::error_info_container> 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

Modified: trunk/boost/exception/info.hpp
==============================================================================
--- trunk/boost/exception/info.hpp (original)
+++ trunk/boost/exception/info.hpp 2008-05-03 15:51:41 EDT (Sat, 03 May 2008)
@@ -39,9 +39,8 @@
 
             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()
                 {


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