Boost logo

Boost-Commit :

From: emil_at_[hidden]
Date: 2008-08-29 00:56:03


Author: emildotchevski
Date: 2008-08-29 00:56:02 EDT (Fri, 29 Aug 2008)
New Revision: 48439
URL: http://svn.boost.org/trac/boost/changeset/48439

Log:
enable_current_exception.hpp decoupled from atomic_count.hpp
Text files modified:
   trunk/boost/exception/detail/cloning_base.hpp | 9 +
   trunk/boost/exception/enable_current_exception.hpp | 108 +++++++------
   trunk/boost/exception_ptr.hpp | 93 ++++++++++-
   trunk/libs/exception/doc/source/boost-exception.reno | 304 ++++++++++++++++++++--------------------
   trunk/libs/exception/test/cloning_test.cpp | 220 ++++++++++++++++++++++++++++
   5 files changed, 515 insertions(+), 219 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-08-29 00:56:02 EDT (Fri, 29 Aug 2008)
@@ -16,12 +16,19 @@
         {
         class clone_base;
 
+ struct
+ new_clone
+ {
+ clone_base const * c_;
+ void (*d_)(clone_base const *);
+ };
+
         class
         cloning_base
             {
             public:
 
- virtual clone_base const * clone() const = 0;
+ virtual new_clone clone() const = 0;
 
             protected:
 

Modified: trunk/boost/exception/enable_current_exception.hpp
==============================================================================
--- trunk/boost/exception/enable_current_exception.hpp (original)
+++ trunk/boost/exception/enable_current_exception.hpp 2008-08-29 00:56:02 EDT (Fri, 29 Aug 2008)
@@ -8,7 +8,6 @@
 
 #include <boost/exception/exception.hpp>
 #include <boost/exception/detail/cloning_base.hpp>
-#include <boost/detail/atomic_count.hpp>
 #include <boost/assert.hpp>
 #include <new>
 
@@ -31,39 +30,8 @@
             {
             }
 
- class
- clone_base:
- public counted_base
- {
- public:
-
- virtual void rethrow() const=0;
- };
-
- struct
- bad_alloc_impl:
- public clone_base,
- public std::bad_alloc
- {
- void
- add_ref() const
- {
- }
-
- void
- release() const
- {
- }
-
- void
- rethrow() const
- {
- throw *this;
- }
- };
-
         template <class T>
- clone_base * make_clone( T const & );
+ new_clone make_clone( T const & );
 
         template <class T>
         class
@@ -80,15 +48,46 @@
                 copy_boost_exception(this,&x);
                 }
 
+ ~clone_impl() throw()
+ {
+ }
+
             private:
 
- clone_base const *
+ new_clone
             clone() const
                 {
                 return make_clone<T>(*this);
                 }
             };
 
+ class
+ clone_base
+ {
+ public:
+
+ virtual void rethrow() const=0;
+ virtual ~clone_base() throw()=0;
+ };
+
+ inline
+ clone_base::
+ ~clone_base() throw()
+ {
+ }
+
+ struct
+ bad_alloc_impl:
+ public clone_base,
+ public std::bad_alloc
+ {
+ void
+ rethrow() const
+ {
+ throw *this;
+ }
+ };
+
         template <class T>
         class
         exception_clone:
@@ -99,27 +98,15 @@
 
             explicit
             exception_clone( T const & x ):
- T(x),
- count_(0)
+ T(x)
                 {
                 copy_boost_exception(this,&x);
                 }
 
             private:
 
- mutable detail::atomic_count count_;
-
- void
- add_ref() const
+ ~exception_clone() throw()
                 {
- ++count_;
- }
-
- void
- release() const
- {
- if( !--count_ )
- delete this;
                 }
 
             void
@@ -129,27 +116,44 @@
                 }
             };
 
+ inline
+ void
+ delete_clone( clone_base const * c )
+ {
+ BOOST_ASSERT(c!=0);
+ delete c;
+ }
+
+ inline
+ void
+ delete_clone_noop( clone_base const * )
+ {
+ }
+
         template <class T>
         inline
- clone_base *
+ new_clone
         make_clone( T const & x )
             {
+ new_clone tmp = {0,0};
             try
                 {
- return new exception_clone<T>(x);
+ tmp.c_=new exception_clone<T>(x);
+ tmp.d_=&delete_clone;
                 }
             catch(
             std::bad_alloc & )
                 {
                 static bad_alloc_impl bad_alloc;
- return &bad_alloc;
+ tmp.c_=&bad_alloc;
+ tmp.d_=&delete_clone_noop;
                 }
             catch(
             ... )
                 {
                 BOOST_ASSERT(0);
- return 0;
                 }
+ return tmp;
             }
         }
 

Modified: trunk/boost/exception_ptr.hpp
==============================================================================
--- trunk/boost/exception_ptr.hpp (original)
+++ trunk/boost/exception_ptr.hpp 2008-08-29 00:56:02 EDT (Fri, 29 Aug 2008)
@@ -8,13 +8,76 @@
 
 #include <boost/exception/enable_current_exception.hpp>
 #include <boost/exception/detail/get_boost_exception.hpp>
-#include <boost/exception/detail/cloning_base.hpp>
+#include <boost/detail/atomic_count.hpp>
 #include <stdexcept>
 #include <new>
 
 namespace
 boost
     {
+ namespace
+ exception_detail
+ {
+ class
+ counted_clone:
+ public counted_base
+ {
+ public:
+
+ counted_clone():
+ count_(0),
+ clone_(0)
+ {
+ }
+
+ void
+ set( new_clone const & nc )
+ {
+ clone_ = nc.c_;
+ clone_deleter_ = nc.d_;
+ BOOST_ASSERT(clone_!=0);
+ BOOST_ASSERT(clone_deleter_!=0);
+ }
+
+ void
+ rethrow() const
+ {
+ BOOST_ASSERT(clone_!=0);
+ clone_->rethrow();
+ }
+
+ private:
+
+ counted_clone( counted_clone const & );
+ counted_clone & operator=( counted_clone const & );
+
+ mutable detail::atomic_count count_;
+ clone_base const * clone_;
+ void (*clone_deleter_)(clone_base const *);
+
+ ~counted_clone() throw()
+ {
+ if( clone_ )
+ clone_deleter_(clone_);
+ }
+
+ void
+ add_ref() const
+ {
+ ++count_;
+ }
+
+ void
+ release() const
+ {
+ if( !--count_ )
+ delete this;
+ }
+ };
+ }
+
+ typedef intrusive_ptr<exception_detail::counted_clone const> exception_ptr;
+
     class
     unknown_exception:
         public exception,
@@ -37,8 +100,6 @@
             }
         };
 
- typedef intrusive_ptr<exception_detail::clone_base const> exception_ptr;
-
     namespace
     exception_detail
         {
@@ -72,17 +133,21 @@
         exception_ptr
         current_exception_std_exception( T const & e1 )
             {
+ intrusive_ptr<exception_detail::counted_clone> x(new exception_detail::counted_clone);
             if( boost::exception const * e2 = get_boost_exception(&e1) )
- return exception_ptr(exception_detail::make_clone(current_exception_std_exception_wrapper<T>(e1,*e2)));
+ x->set(exception_detail::make_clone(current_exception_std_exception_wrapper<T>(e1,*e2)));
             else
- return exception_ptr(exception_detail::make_clone(current_exception_std_exception_wrapper<T>(e1)));
+ x->set(exception_detail::make_clone(current_exception_std_exception_wrapper<T>(e1)));
+ return x;
             }
 
         inline
         exception_ptr
         current_exception_unknown_exception()
             {
- return exception_ptr(exception_detail::make_clone(unknown_exception()));
+ intrusive_ptr<exception_detail::counted_clone> x(new exception_detail::counted_clone);
+ x->set(exception_detail::make_clone(unknown_exception()));
+ return x;
             }
 
         inline
@@ -90,7 +155,11 @@
         current_exception_unknown_std_exception( std::exception const & e )
             {
             if( boost::exception const * be = get_boost_exception(&e) )
- return exception_ptr(exception_detail::make_clone(unknown_exception(*be)));
+ {
+ intrusive_ptr<exception_detail::counted_clone> x(new exception_detail::counted_clone);
+ x->set(exception_detail::make_clone(unknown_exception(*be)));
+ return x;
+ }
             else
                 return current_exception_unknown_exception();
             }
@@ -99,7 +168,9 @@
         exception_ptr
         current_exception_unknown_boost_exception( boost::exception const & e )
             {
- return exception_ptr(exception_detail::make_clone(unknown_exception(e)));
+ intrusive_ptr<exception_detail::counted_clone> x(new exception_detail::counted_clone);
+ x->set(exception_detail::make_clone(unknown_exception(e)));
+ return x;
             }
         }
 
@@ -114,9 +185,9 @@
         catch(
         exception_detail::cloning_base & e )
             {
- exception_detail::clone_base const * c = e.clone();
- BOOST_ASSERT(c!=0);
- return exception_ptr(c);
+ intrusive_ptr<exception_detail::counted_clone> x(new exception_detail::counted_clone);
+ x->set(e.clone());
+ return x;
             }
         catch(
         std::invalid_argument & e )

Modified: trunk/libs/exception/doc/source/boost-exception.reno
==============================================================================
--- trunk/libs/exception/doc/source/boost-exception.reno (original)
+++ trunk/libs/exception/doc/source/boost-exception.reno 2008-08-29 00:56:02 EDT (Fri, 29 Aug 2008)
@@ -54,14 +54,14 @@
                                                                                                                                         <stream_hook_path>
                                                                                                                                                 <container>
                                                                                                                                                         <size>2</size>
- <strong>0FEF784CA0A4FF86352946012E280A01EA22BA7DF8A19B243DC76A5125D4042F</strong>
- <weak>3547540308</weak>
- <size>4879</size>
- <position>531</position>
+ <strong>548365B35C2AA24908DAA42A1F359940FCD1DE69D642E074E821AC86DCE54029</strong>
+ <weak>3649242015</weak>
+ <size>6823</size>
+ <position>521</position>
                                                                                                                                                         <strong>156B870761DB092CE4269C1173B479A344A1041BA2B883765AF19A72B371D776</strong>
                                                                                                                                                         <weak>3239976720</weak>
                                                                                                                                                         <size>117</size>
- <position>4756</position>
+ <position>6700</position>
                                                                                                                                                 </container>
                                                                                                                                         </stream_hook_path>
                                                                                                                                 </hook>
@@ -152,14 +152,14 @@
                                                                                                                                         <stream_hook_path>
                                                                                                                                                 <container>
                                                                                                                                                         <size>2</size>
- <strong>0FEF784CA0A4FF86352946012E280A01EA22BA7DF8A19B243DC76A5125D4042F</strong>
- <weak>3547540308</weak>
- <size>4879</size>
- <position>531</position>
- <strong>ED09F845070FF7D381BE5EFB6B55313FD09FBA16B64B69992410380EFA45519C</strong>
- <weak>2051939590</weak>
- <size>78</size>
- <position>433</position>
+ <strong>548365B35C2AA24908DAA42A1F359940FCD1DE69D642E074E821AC86DCE54029</strong>
+ <weak>3649242015</weak>
+ <size>6823</size>
+ <position>521</position>
+ <strong>AB48477C625A1E68BF74B055D380697B5761C4DBA41F8B2148F6A0F8A2BAC38E</strong>
+ <weak>3683655261</weak>
+ <size>81</size>
+ <position>1480</position>
                                                                                                                                                 </container>
                                                                                                                                         </stream_hook_path>
                                                                                                                                 </hook>
@@ -250,10 +250,10 @@
                                                                                                                                         <stream_hook_path>
                                                                                                                                                 <container>
                                                                                                                                                         <size>1</size>
- <strong>06FF83AB627CF01DE016240E3664241F90A142A3963F0EAFAE55E4A11742D7FC</strong>
- <weak>3393983433</weak>
- <size>3433</size>
- <position>227</position>
+ <strong>59EC111578A82535A1DC3EDB486F029664F751D86C2C90D0D3FE0BAFAA87387E</strong>
+ <weak>3274250395</weak>
+ <size>3418</size>
+ <position>323</position>
                                                                                                                                                 </container>
                                                                                                                                         </stream_hook_path>
                                                                                                                                 </hook>
@@ -295,9 +295,9 @@
                                                                                                                                         <stream_hook_path>
                                                                                                                                                 <container>
                                                                                                                                                         <size>1</size>
- <strong>208AD3E1D28FC8033210811C4E44D738A41F0B0B7F747467413A685125A50544</strong>
- <weak>2712565394</weak>
- <size>5087</size>
+ <strong>F052D2548BCDFFFA0DA6CB0AC3731B15EBE7E34F357A4485F0FCD205457859CA</strong>
+ <weak>175131392</weak>
+ <size>7021</size>
                                                                                                                                                         <position>323</position>
                                                                                                                                                 </container>
                                                                                                                                         </stream_hook_path>
@@ -749,14 +749,14 @@
                                                                                                                                         <stream_hook_path>
                                                                                                                                                 <container>
                                                                                                                                                         <size>2</size>
- <strong>0FEF784CA0A4FF86352946012E280A01EA22BA7DF8A19B243DC76A5125D4042F</strong>
- <weak>3547540308</weak>
- <size>4879</size>
- <position>531</position>
+ <strong>548365B35C2AA24908DAA42A1F359940FCD1DE69D642E074E821AC86DCE54029</strong>
+ <weak>3649242015</weak>
+ <size>6823</size>
+ <position>521</position>
                                                                                                                                                         <strong>F87D7E0321BDDAE23D5A6667CB12116411468AEC54E3B35FB9C8CA94BFECA41E</strong>
                                                                                                                                                         <weak>1149388739</weak>
                                                                                                                                                         <size>296</size>
- <position>4458</position>
+ <position>6402</position>
                                                                                                                                                 </container>
                                                                                                                                         </stream_hook_path>
                                                                                                                                 </hook>
@@ -1161,14 +1161,14 @@
                                                                                                                                         <stream_hook_path>
                                                                                                                                                 <container>
                                                                                                                                                         <size>2</size>
- <strong>0FEF784CA0A4FF86352946012E280A01EA22BA7DF8A19B243DC76A5125D4042F</strong>
- <weak>3547540308</weak>
- <size>4879</size>
- <position>531</position>
- <strong>9DEEF8ED70BF74F501A96BA5DE5BFD42FAD16DE333ABE189E512C332586FC465</strong>
- <weak>2250569940</weak>
- <size>1893</size>
- <position>2563</position>
+ <strong>548365B35C2AA24908DAA42A1F359940FCD1DE69D642E074E821AC86DCE54029</strong>
+ <weak>3649242015</weak>
+ <size>6823</size>
+ <position>521</position>
+ <strong>5B9A60CD7925F05B8F4A0A8F690EC320226187C26D9D6DD9F3A7793C74A9F4FC</strong>
+ <weak>3344368450</weak>
+ <size>1912</size>
+ <position>4488</position>
                                                                                                                                                 </container>
                                                                                                                                         </stream_hook_path>
                                                                                                                                 </hook>
@@ -1545,14 +1545,14 @@
                                                                                                                                         <stream_hook_path>
                                                                                                                                                 <container>
                                                                                                                                                         <size>2</size>
- <strong>0FEF784CA0A4FF86352946012E280A01EA22BA7DF8A19B243DC76A5125D4042F</strong>
- <weak>3547540308</weak>
- <size>4879</size>
- <position>531</position>
+ <strong>548365B35C2AA24908DAA42A1F359940FCD1DE69D642E074E821AC86DCE54029</strong>
+ <weak>3649242015</weak>
+ <size>6823</size>
+ <position>521</position>
                                                                                                                                                         <strong>A098B6FA5BC8E72E0E69C0323195FCC142AE807564C6892FCBD88588F2FBE049</strong>
                                                                                                                                                         <weak>2579522516</weak>
                                                                                                                                                         <size>405</size>
- <position>26</position>
+ <position>1563</position>
                                                                                                                                                 </container>
                                                                                                                                         </stream_hook_path>
                                                                                                                                 </hook>
@@ -1594,14 +1594,14 @@
                                                                                                                                         <stream_hook_path>
                                                                                                                                                 <container>
                                                                                                                                                         <size>2</size>
- <strong>BC2FB1723D280E870C34C192CB356C520C5C1C23EA5C209797F5DE3F15758F24</strong>
- <weak>997637066</weak>
- <size>3154</size>
- <position>506</position>
+ <strong>3A4D0506DEDA25E46C6F3B3936898F829C428AF153A7B1B5391B02ABA4C0AD0D</strong>
+ <weak>1800726291</weak>
+ <size>3277</size>
+ <position>464</position>
                                                                                                                                                         <strong>DF9EA87B0140AACF4422F1B76F6A6A409C15F32858BBBA85A35981A824C56BA9</strong>
                                                                                                                                                         <weak>1137981799</weak>
                                                                                                                                                         <size>192</size>
- <position>2956</position>
+ <position>3079</position>
                                                                                                                                                 </container>
                                                                                                                                         </stream_hook_path>
                                                                                                                                 </hook>
@@ -7791,24 +7791,28 @@
                                                                         <hook>
                                                                                 <stream_hook_path>
                                                                                         <container>
- <size>1</size>
- <strong>4DC5257313CB18D2FB860A51C10E0CA1F26C0130EF7884BEA62F2B9202796B14</strong>
- <weak>1113469887</weak>
- <size>1807</size>
- <position>91</position>
+ <size>2</size>
+ <strong>3A4D0506DEDA25E46C6F3B3936898F829C428AF153A7B1B5391B02ABA4C0AD0D</strong>
+ <weak>1800726291</weak>
+ <size>3277</size>
+ <position>464</position>
+ <strong>DF9EA87B0140AACF4422F1B76F6A6A409C15F32858BBBA85A35981A824C56BA9</strong>
+ <weak>1137981799</weak>
+ <size>192</size>
+ <position>3079</position>
                                                                                         </container>
                                                                                 </stream_hook_path>
                                                                         </hook>
                                                                         <file>
                                                                                 <path>
                                                                                         <empty>0</empty>
- <string>../../../../boost/throw_exception.hpp</string>
+ <string>../../../../boost/exception/enable_current_exception.hpp</string>
                                                                                         <type>0</type>
                                                                                         <base>0</base>
                                                                                 </path>
                                                                         </file>
                                                                         <shared_ptr>
- <id>-36</id>
+ <id>-38</id>
                                                                         </shared_ptr>
                                                                 </pair>
                                                                 <pair>
@@ -7816,51 +7820,47 @@
                                                                                 <stream_hook_path>
                                                                                         <container>
                                                                                                 <size>1</size>
- <strong>FC684D0DD5A9732B4130F2AB3DB6E0491D0F523E14B7FB738B2019EA2C7F8717</strong>
- <weak>2229778754</weak>
- <size>631</size>
- <position>319</position>
+ <strong>4DC5257313CB18D2FB860A51C10E0CA1F26C0130EF7884BEA62F2B9202796B14</strong>
+ <weak>1113469887</weak>
+ <size>1807</size>
+ <position>91</position>
                                                                                         </container>
                                                                                 </stream_hook_path>
                                                                         </hook>
                                                                         <file>
                                                                                 <path>
                                                                                         <empty>0</empty>
- <string>../../example/cloning_2.cpp</string>
+ <string>../../../../boost/throw_exception.hpp</string>
                                                                                         <type>0</type>
                                                                                         <base>0</base>
                                                                                 </path>
                                                                         </file>
                                                                         <shared_ptr>
- <id>-34</id>
+ <id>-36</id>
                                                                         </shared_ptr>
                                                                 </pair>
                                                                 <pair>
                                                                         <hook>
                                                                                 <stream_hook_path>
                                                                                         <container>
- <size>2</size>
- <strong>BC2FB1723D280E870C34C192CB356C520C5C1C23EA5C209797F5DE3F15758F24</strong>
- <weak>997637066</weak>
- <size>3154</size>
- <position>506</position>
- <strong>DF9EA87B0140AACF4422F1B76F6A6A409C15F32858BBBA85A35981A824C56BA9</strong>
- <weak>1137981799</weak>
- <size>192</size>
- <position>2956</position>
+ <size>1</size>
+ <strong>FC684D0DD5A9732B4130F2AB3DB6E0491D0F523E14B7FB738B2019EA2C7F8717</strong>
+ <weak>2229778754</weak>
+ <size>631</size>
+ <position>319</position>
                                                                                         </container>
                                                                                 </stream_hook_path>
                                                                         </hook>
                                                                         <file>
                                                                                 <path>
                                                                                         <empty>0</empty>
- <string>../../../../boost/exception/enable_current_exception.hpp</string>
+ <string>../../example/cloning_2.cpp</string>
                                                                                         <type>0</type>
                                                                                         <base>0</base>
                                                                                 </path>
                                                                         </file>
                                                                         <shared_ptr>
- <id>-38</id>
+ <id>-34</id>
                                                                         </shared_ptr>
                                                                 </pair>
                                                                 <pair>
@@ -7868,14 +7868,14 @@
                                                                                 <stream_hook_path>
                                                                                         <container>
                                                                                                 <size>2</size>
- <strong>0FEF784CA0A4FF86352946012E280A01EA22BA7DF8A19B243DC76A5125D4042F</strong>
- <weak>3547540308</weak>
- <size>4879</size>
- <position>531</position>
+ <strong>548365B35C2AA24908DAA42A1F359940FCD1DE69D642E074E821AC86DCE54029</strong>
+ <weak>3649242015</weak>
+ <size>6823</size>
+ <position>521</position>
                                                                                                 <strong>F87D7E0321BDDAE23D5A6667CB12116411468AEC54E3B35FB9C8CA94BFECA41E</strong>
                                                                                                 <weak>1149388739</weak>
                                                                                                 <size>296</size>
- <position>4458</position>
+ <position>6402</position>
                                                                                         </container>
                                                                                 </stream_hook_path>
                                                                         </hook>
@@ -7896,14 +7896,14 @@
                                                                                 <stream_hook_path>
                                                                                         <container>
                                                                                                 <size>2</size>
- <strong>0FEF784CA0A4FF86352946012E280A01EA22BA7DF8A19B243DC76A5125D4042F</strong>
- <weak>3547540308</weak>
- <size>4879</size>
- <position>531</position>
+ <strong>548365B35C2AA24908DAA42A1F359940FCD1DE69D642E074E821AC86DCE54029</strong>
+ <weak>3649242015</weak>
+ <size>6823</size>
+ <position>521</position>
                                                                                                 <strong>A098B6FA5BC8E72E0E69C0323195FCC142AE807564C6892FCBD88588F2FBE049</strong>
                                                                                                 <weak>2579522516</weak>
                                                                                                 <size>405</size>
- <position>26</position>
+ <position>1563</position>
                                                                                         </container>
                                                                                 </stream_hook_path>
                                                                         </hook>
@@ -7924,14 +7924,14 @@
                                                                                 <stream_hook_path>
                                                                                         <container>
                                                                                                 <size>2</size>
- <strong>0FEF784CA0A4FF86352946012E280A01EA22BA7DF8A19B243DC76A5125D4042F</strong>
- <weak>3547540308</weak>
- <size>4879</size>
- <position>531</position>
- <strong>9DEEF8ED70BF74F501A96BA5DE5BFD42FAD16DE333ABE189E512C332586FC465</strong>
- <weak>2250569940</weak>
- <size>1893</size>
- <position>2563</position>
+ <strong>548365B35C2AA24908DAA42A1F359940FCD1DE69D642E074E821AC86DCE54029</strong>
+ <weak>3649242015</weak>
+ <size>6823</size>
+ <position>521</position>
+ <strong>156B870761DB092CE4269C1173B479A344A1041BA2B883765AF19A72B371D776</strong>
+ <weak>3239976720</weak>
+ <size>117</size>
+ <position>6700</position>
                                                                                         </container>
                                                                                 </stream_hook_path>
                                                                         </hook>
@@ -7944,7 +7944,7 @@
                                                                                 </path>
                                                                         </file>
                                                                         <shared_ptr>
- <id>-29</id>
+ <id>-5</id>
                                                                         </shared_ptr>
                                                                 </pair>
                                                                 <pair>
@@ -7952,14 +7952,14 @@
                                                                                 <stream_hook_path>
                                                                                         <container>
                                                                                                 <size>2</size>
- <strong>0FEF784CA0A4FF86352946012E280A01EA22BA7DF8A19B243DC76A5125D4042F</strong>
- <weak>3547540308</weak>
- <size>4879</size>
- <position>531</position>
- <strong>156B870761DB092CE4269C1173B479A344A1041BA2B883765AF19A72B371D776</strong>
- <weak>3239976720</weak>
- <size>117</size>
- <position>4756</position>
+ <strong>548365B35C2AA24908DAA42A1F359940FCD1DE69D642E074E821AC86DCE54029</strong>
+ <weak>3649242015</weak>
+ <size>6823</size>
+ <position>521</position>
+ <strong>AB48477C625A1E68BF74B055D380697B5761C4DBA41F8B2148F6A0F8A2BAC38E</strong>
+ <weak>3683655261</weak>
+ <size>81</size>
+ <position>1480</position>
                                                                                         </container>
                                                                                 </stream_hook_path>
                                                                         </hook>
@@ -7972,7 +7972,7 @@
                                                                                 </path>
                                                                         </file>
                                                                         <shared_ptr>
- <id>-5</id>
+ <id>-7</id>
                                                                         </shared_ptr>
                                                                 </pair>
                                                                 <pair>
@@ -7980,14 +7980,14 @@
                                                                                 <stream_hook_path>
                                                                                         <container>
                                                                                                 <size>2</size>
- <strong>0FEF784CA0A4FF86352946012E280A01EA22BA7DF8A19B243DC76A5125D4042F</strong>
- <weak>3547540308</weak>
- <size>4879</size>
- <position>531</position>
- <strong>ED09F845070FF7D381BE5EFB6B55313FD09FBA16B64B69992410380EFA45519C</strong>
- <weak>2051939590</weak>
- <size>78</size>
- <position>433</position>
+ <strong>548365B35C2AA24908DAA42A1F359940FCD1DE69D642E074E821AC86DCE54029</strong>
+ <weak>3649242015</weak>
+ <size>6823</size>
+ <position>521</position>
+ <strong>5B9A60CD7925F05B8F4A0A8F690EC320226187C26D9D6DD9F3A7793C74A9F4FC</strong>
+ <weak>3344368450</weak>
+ <size>1912</size>
+ <position>4488</position>
                                                                                         </container>
                                                                                 </stream_hook_path>
                                                                         </hook>
@@ -8000,7 +8000,7 @@
                                                                                 </path>
                                                                         </file>
                                                                         <shared_ptr>
- <id>-7</id>
+ <id>-29</id>
                                                                         </shared_ptr>
                                                                 </pair>
                                                                 <pair>
@@ -8079,30 +8079,6 @@
                                                                         <hook>
                                                                                 <stream_hook_path>
                                                                                         <container>
- <size>1</size>
- <strong>208AD3E1D28FC8033210811C4E44D738A41F0B0B7F747467413A685125A50544</strong>
- <weak>2712565394</weak>
- <size>5087</size>
- <position>323</position>
- </container>
- </stream_hook_path>
- </hook>
- <file>
- <path>
- <empty>0</empty>
- <string>../../../../boost/exception_ptr.hpp</string>
- <type>0</type>
- <base>0</base>
- </path>
- </file>
- <shared_ptr>
- <id>-10</id>
- </shared_ptr>
- </pair>
- <pair>
- <hook>
- <stream_hook_path>
- <container>
                                                                                                 <size>2</size>
                                                                                                 <strong>3EFECC50102590C4E9074D4F86B0E8F831D933193CCF70B8D80E8A0CF345C150</strong>
                                                                                                 <weak>877841526</weak>
@@ -8435,6 +8411,30 @@
                                                                         <hook>
                                                                                 <stream_hook_path>
                                                                                         <container>
+ <size>1</size>
+ <strong>59EC111578A82535A1DC3EDB486F029664F751D86C2C90D0D3FE0BAFAA87387E</strong>
+ <weak>3274250395</weak>
+ <size>3418</size>
+ <position>323</position>
+ </container>
+ </stream_hook_path>
+ </hook>
+ <file>
+ <path>
+ <empty>0</empty>
+ <string>../../../../boost/exception/enable_current_exception.hpp</string>
+ <type>0</type>
+ <base>0</base>
+ </path>
+ </file>
+ <shared_ptr>
+ <id>-9</id>
+ </shared_ptr>
+ </pair>
+ <pair>
+ <hook>
+ <stream_hook_path>
+ <container>
                                                                                                 <size>2</size>
                                                                                                 <strong>612485E090D76B2CC43C1A296F813075BA165C2496082E78E939F10B3DA8E09A</strong>
                                                                                                 <weak>1770110914</weak>
@@ -8535,6 +8535,30 @@
                                                                         <hook>
                                                                                 <stream_hook_path>
                                                                                         <container>
+ <size>1</size>
+ <strong>F052D2548BCDFFFA0DA6CB0AC3731B15EBE7E34F357A4485F0FCD205457859CA</strong>
+ <weak>175131392</weak>
+ <size>7021</size>
+ <position>323</position>
+ </container>
+ </stream_hook_path>
+ </hook>
+ <file>
+ <path>
+ <empty>0</empty>
+ <string>../../../../boost/exception_ptr.hpp</string>
+ <type>0</type>
+ <base>0</base>
+ </path>
+ </file>
+ <shared_ptr>
+ <id>-10</id>
+ </shared_ptr>
+ </pair>
+ <pair>
+ <hook>
+ <stream_hook_path>
+ <container>
                                                                                                 <size>2</size>
                                                                                                 <strong>0C9E5FE5B32FD3F31875CF6AD87A485CACC42754EE56F0E72D9D9749734959D5</strong>
                                                                                                 <weak>2969409401</weak>
@@ -8711,30 +8735,6 @@
                                                                                 <id>-19</id>
                                                                         </shared_ptr>
                                                                 </pair>
- <pair>
- <hook>
- <stream_hook_path>
- <container>
- <size>1</size>
- <strong>06FF83AB627CF01DE016240E3664241F90A142A3963F0EAFAE55E4A11742D7FC</strong>
- <weak>3393983433</weak>
- <size>3433</size>
- <position>227</position>
- </container>
- </stream_hook_path>
- </hook>
- <file>
- <path>
- <empty>0</empty>
- <string>../../../../boost/exception/enable_current_exception.hpp</string>
- <type>0</type>
- <base>0</base>
- </path>
- </file>
- <shared_ptr>
- <id>-9</id>
- </shared_ptr>
- </pair>
                                                         </sorted>
                                                 </index>
                                         </object>

Modified: trunk/libs/exception/test/cloning_test.cpp
==============================================================================
--- trunk/libs/exception/test/cloning_test.cpp (original)
+++ trunk/libs/exception/test/cloning_test.cpp 2008-08-29 00:56:02 EDT (Fri, 29 Aug 2008)
@@ -4,20 +4,230 @@
 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
 #include <boost/exception_ptr.hpp>
+#include <boost/exception/get_error_info.hpp>
+#include <boost/exception/info.hpp>
 #include <boost/detail/lightweight_test.hpp>
+#include <string>
+
+typedef boost::error_info<struct my_tag,int> my_info;
+
+struct
+derives_nothing
+ {
+ int & count;
+
+ explicit
+ derives_nothing( int & count ):
+ count(count)
+ {
+ ++count;
+ }
+
+ derives_nothing( derives_nothing const & x ):
+ count(x.count)
+ {
+ ++count;
+ }
+
+ ~derives_nothing()
+ {
+ --count;
+ }
+ };
 
 struct
-test_exception:
+derives_std_exception:
     std::exception
     {
     };
 
+struct
+derives_std_boost_exception:
+ std::exception,
+ boost::exception
+ {
+ };
+
+struct
+derives_boost_exception:
+ boost::exception
+ {
+ };
+
+template <class T>
+void
+test_std_exception()
+ {
+ try
+ {
+ throw T();
+ }
+ catch(
+ ... )
+ {
+ boost::exception_ptr p = boost::current_exception();
+ try
+ {
+ rethrow_exception(p);
+ BOOST_TEST(false);
+ }
+ catch(
+ T & )
+ {
+ }
+ catch(
+ ... )
+ {
+ BOOST_TEST(false);
+ }
+ }
+ }
+
+template <class T>
+void
+test_std_exception_what()
+ {
+ try
+ {
+ throw T("what");
+ }
+ catch(
+ ... )
+ {
+ boost::exception_ptr p = boost::current_exception();
+ try
+ {
+ rethrow_exception(p);
+ BOOST_TEST(false);
+ }
+ catch(
+ T & x )
+ {
+ BOOST_TEST(std::string("what")==x.what());
+ }
+ catch(
+ ... )
+ {
+ BOOST_TEST(false);
+ }
+ }
+ }
+
 int
 main()
     {
+ int count=0;
+ try
+ {
+ throw boost::enable_current_exception(derives_nothing(count));
+ }
+ catch(
+ ... )
+ {
+ boost::exception_ptr p = boost::current_exception();
+ try
+ {
+ rethrow_exception(p);
+ BOOST_TEST(false);
+ }
+ catch(
+ derives_nothing & )
+ {
+ }
+ catch(
+ ... )
+ {
+ BOOST_TEST(false);
+ }
+ }
+ BOOST_TEST(count==0);
+
+ try
+ {
+ throw boost::enable_current_exception(derives_std_exception());
+ }
+ catch(
+ ... )
+ {
+ boost::exception_ptr p = boost::current_exception();
+ try
+ {
+ rethrow_exception(p);
+ BOOST_TEST(false);
+ }
+ catch(
+ derives_std_exception & )
+ {
+ }
+ catch(
+ ... )
+ {
+ BOOST_TEST(false);
+ }
+ }
+
+ try
+ {
+ throw derives_std_exception();
+ }
+ catch(
+ ... )
+ {
+ boost::exception_ptr p = boost::current_exception();
+ try
+ {
+ rethrow_exception(p);
+ BOOST_TEST(false);
+ }
+ catch(
+ boost::unknown_exception & )
+ {
+ }
+ catch(
+ ... )
+ {
+ BOOST_TEST(false);
+ }
+ }
+
+ test_std_exception_what<std::invalid_argument>();
+ test_std_exception_what<std::out_of_range>();
+ test_std_exception_what<std::logic_error>();
+ test_std_exception<std::bad_alloc>();
+ test_std_exception<std::bad_cast>();
+ test_std_exception<std::bad_typeid>();
+ test_std_exception<std::bad_exception>();
+
+ try
+ {
+ throw derives_std_boost_exception() << my_info(42);
+ }
+ catch(
+ ... )
+ {
+ boost::exception_ptr p = boost::current_exception();
+ try
+ {
+ rethrow_exception(p);
+ BOOST_TEST(false);
+ }
+ catch(
+ boost::unknown_exception & x )
+ {
+ BOOST_TEST(boost::get_error_info<my_info>(x));
+ if( boost::shared_ptr<int const> p=boost::get_error_info<my_info>(x) )
+ BOOST_TEST(*p==42);
+ }
+ catch(
+ ... )
+ {
+ BOOST_TEST(false);
+ }
+ }
+
     try
         {
- throw boost::enable_current_exception(test_exception());
+ throw derives_boost_exception() << my_info(42);
         }
     catch(
     ... )
@@ -29,8 +239,11 @@
             BOOST_TEST(false);
             }
         catch(
- test_exception & )
+ boost::unknown_exception & x )
             {
+ BOOST_TEST(boost::get_error_info<my_info>(x));
+ if( boost::shared_ptr<int const> p=boost::get_error_info<my_info>(x) )
+ BOOST_TEST(*p==42);
             }
         catch(
         ... )
@@ -38,5 +251,6 @@
             BOOST_TEST(false);
             }
         }
+
     return boost::report_errors();
     }


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