|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r68202 - in trunk/boost/exception: . detail
From: emil_at_[hidden]
Date: 2011-01-17 02:01:41
Author: emildotchevski
Date: 2011-01-17 02:01:35 EST (Mon, 17 Jan 2011)
New Revision: 68202
URL: http://svn.boost.org/trac/boost/changeset/68202
Log:
Converted exception_ptr from a shared_ptr typedef to a stand-alone class to allow simpler declaration of namespace boost { class exception_ptr; }
Text files modified:
trunk/boost/exception/detail/exception_ptr.hpp | 44 ++++++++++++++++++++++++++++++++++-----
trunk/boost/exception/errinfo_nested_exception.hpp | 2
2 files changed, 39 insertions(+), 7 deletions(-)
Modified: trunk/boost/exception/detail/exception_ptr.hpp
==============================================================================
--- trunk/boost/exception/detail/exception_ptr.hpp (original)
+++ trunk/boost/exception/detail/exception_ptr.hpp 2011-01-17 02:01:35 EST (Mon, 17 Jan 2011)
@@ -29,10 +29,42 @@
namespace
boost
{
- typedef shared_ptr<exception_detail::clone_base const> exception_ptr;
-
+ class exception_ptr;
+ void rethrow_exception( exception_ptr const & );
exception_ptr current_exception();
+ class
+ exception_ptr
+ {
+ typedef boost::shared_ptr<exception_detail::clone_base const> 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 <class T>
inline
exception_ptr
@@ -89,7 +121,7 @@
throw_function(BOOST_CURRENT_FUNCTION) <<
throw_file(__FILE__) <<
throw_line(__LINE__);
- static exception_ptr ep(new exception_detail::clone_impl<Exception>(c));
+ static exception_ptr ep(shared_ptr<exception_detail::clone_base const>(new exception_detail::clone_impl<Exception>(c)));
return ep;
}
@@ -272,7 +304,7 @@
success:
{
BOOST_ASSERT(e!=0);
- return exception_ptr(e);
+ return exception_ptr(shared_ptr<exception_detail::clone_base const>(e));
}
case exception_detail::clone_current_exception_result::
bad_alloc:
@@ -299,7 +331,7 @@
catch(
exception_detail::clone_base & e )
{
- return exception_ptr(e.clone());
+ return exception_ptr(shared_ptr<exception_detail::clone_base const>(e.clone()));
}
catch(
std::domain_error & e )
@@ -421,7 +453,7 @@
rethrow_exception( exception_ptr const & p )
{
BOOST_ASSERT(p);
- p->rethrow();
+ p.ptr_->rethrow();
}
inline
Modified: trunk/boost/exception/errinfo_nested_exception.hpp
==============================================================================
--- trunk/boost/exception/errinfo_nested_exception.hpp (original)
+++ trunk/boost/exception/errinfo_nested_exception.hpp 2011-01-17 02:01:35 EST (Mon, 17 Jan 2011)
@@ -12,7 +12,7 @@
namespace exception_detail { class clone_base; };
template <class Tag,class T> class error_info;
template <class T> class shared_ptr;
- typedef shared_ptr<exception_detail::clone_base const> exception_ptr;
+ class exception_ptr;
typedef error_info<struct errinfo_nested_exception_,exception_ptr> errinfo_nested_exception;
}
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