From 6b0bfad6bfffd40f0744071c53ab69bb6a0f0d19 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Mon, 17 Jan 2011 07:01:35 +0000 Subject: [PATCH] Converted exception_ptr from a shared_ptr typedef to a stand-alone class to allow simpler declaration of namespace boost { class exception_ptr; } [SVN r68202] --- .../boost/exception/detail/exception_ptr.hpp | 44 ++++++++++++++++--- .../exception/errinfo_nested_exception.hpp | 2 +- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/include/boost/exception/detail/exception_ptr.hpp b/include/boost/exception/detail/exception_ptr.hpp index 74f451c..af8f6f8 100644 --- a/include/boost/exception/detail/exception_ptr.hpp +++ b/include/boost/exception/detail/exception_ptr.hpp @@ -29,10 +29,42 @@ namespace boost { - typedef shared_ptr exception_ptr; - + class exception_ptr; + void rethrow_exception( exception_ptr const & ); exception_ptr current_exception(); + class + exception_ptr + { + typedef boost::shared_ptr impl; + impl ptr_; + friend void rethrow_exception( exception_ptr const & ); + typedef exception_detail::clone_base const * (impl::*unspecified_bool_type)() const; + public: + exception_ptr() + { + } + explicit + exception_ptr( impl const & ptr ): + ptr_(ptr) + { + } + bool + operator==( exception_ptr const & other ) const + { + return ptr_==other.ptr_; + } + bool + operator!=( exception_ptr const & other ) const + { + return ptr_!=other.ptr_; + } + operator unspecified_bool_type() const + { + return ptr_?&impl::get:0; + } + }; + template inline exception_ptr @@ -89,7 +121,7 @@ boost throw_function(BOOST_CURRENT_FUNCTION) << throw_file(__FILE__) << throw_line(__LINE__); - static exception_ptr ep(new exception_detail::clone_impl(c)); + static exception_ptr ep(shared_ptr(new exception_detail::clone_impl(c))); return ep; } @@ -272,7 +304,7 @@ boost success: { BOOST_ASSERT(e!=0); - return exception_ptr(e); + return exception_ptr(shared_ptr(e)); } case exception_detail::clone_current_exception_result:: bad_alloc: @@ -299,7 +331,7 @@ boost catch( exception_detail::clone_base & e ) { - return exception_ptr(e.clone()); + return exception_ptr(shared_ptr(e.clone())); } catch( std::domain_error & e ) @@ -421,7 +453,7 @@ boost rethrow_exception( exception_ptr const & p ) { BOOST_ASSERT(p); - p->rethrow(); + p.ptr_->rethrow(); } inline diff --git a/include/boost/exception/errinfo_nested_exception.hpp b/include/boost/exception/errinfo_nested_exception.hpp index e4e75d9..29c6f4a 100644 --- a/include/boost/exception/errinfo_nested_exception.hpp +++ b/include/boost/exception/errinfo_nested_exception.hpp @@ -12,7 +12,7 @@ boost namespace exception_detail { class clone_base; }; template class error_info; template class shared_ptr; - typedef shared_ptr exception_ptr; + class exception_ptr; typedef error_info errinfo_nested_exception; }