|
Boost-Commit : |
From: d.frey_at_[hidden]
Date: 2008-04-28 03:17:12
Author: daniel_frey
Date: 2008-04-28 03:17:11 EDT (Mon, 28 Apr 2008)
New Revision: 44837
URL: http://svn.boost.org/trac/boost/changeset/44837
Log:
Improved sp_deleter_wrapper implementation
Text files modified:
trunk/boost/enable_shared_from_this.hpp | 5 ++---
trunk/boost/shared_ptr.hpp | 23 +++++++++--------------
2 files changed, 11 insertions(+), 17 deletions(-)
Modified: trunk/boost/enable_shared_from_this.hpp
==============================================================================
--- trunk/boost/enable_shared_from_this.hpp (original)
+++ trunk/boost/enable_shared_from_this.hpp 2008-04-28 03:17:11 EDT (Mon, 28 Apr 2008)
@@ -89,10 +89,9 @@
}else if( !_shared_count.empty() )
{
BOOST_ASSERT( owner.unique() ); // no weak_ptrs to owner should exist either, but there's no way to check that
- typedef detail::sp_deleter_wrapper D;
- D * pd = static_cast<D *>( _shared_count.get_deleter( BOOST_SP_TYPEID(D) ) );
+ detail::sp_deleter_wrapper * pd = detail::basic_get_deleter<detail::sp_deleter_wrapper>( _shared_count );
BOOST_ASSERT( pd != 0 );
- pd->set_deleter( owner );
+ pd->set_deleter( owner.get_shared_count() );
owner.reset( _shared_count, owner.get() );
detail::shared_count().swap( _shared_count );
}
Modified: trunk/boost/shared_ptr.hpp
==============================================================================
--- trunk/boost/shared_ptr.hpp (original)
+++ trunk/boost/shared_ptr.hpp 2008-04-28 03:17:11 EDT (Mon, 28 Apr 2008)
@@ -497,11 +497,6 @@
return pn < rhs.pn;
}
- void * _internal_get_deleter( detail::sp_typeinfo const & ti ) const
- {
- return pn.get_deleter( ti );
- }
-
// atomic access
#if !defined(BOOST_SP_NO_ATOMIC_ACCESS)
@@ -701,35 +696,35 @@
// g++ 2.9x doesn't allow static_cast<X const *>(void *)
// apparently EDG 2.38 and HP aCC A.03.35 also don't accept it
-template<class D, class T> D * basic_get_deleter(shared_ptr<T> const & p)
+template<class D> D * basic_get_deleter(shared_count const & c)
{
- void const * q = p._internal_get_deleter(BOOST_SP_TYPEID(D));
+ void const * q = c.get_deleter(BOOST_SP_TYPEID(D));
return const_cast<D *>(static_cast<D const *>(q));
}
#else
-template<class D, class T> D * basic_get_deleter(shared_ptr<T> const & p)
+template<class D> D * basic_get_deleter(shared_count const & c)
{
- return static_cast<D *>(p._internal_get_deleter(BOOST_SP_TYPEID(D)));
+ return static_cast<D *>(c.get_deleter(BOOST_SP_TYPEID(D)));
}
#endif
class sp_deleter_wrapper
{
- shared_ptr<const void> _deleter;
+ detail::shared_count _deleter;
public:
sp_deleter_wrapper()
{}
- void set_deleter(const shared_ptr<const void> &deleter)
+ void set_deleter(shared_count const &deleter)
{
_deleter = deleter;
}
void operator()(const void *)
{
BOOST_ASSERT(_deleter.use_count() <= 1);
- _deleter.reset();
+ detail::shared_count().swap( _deleter );
}
template<typename D>
D* get_deleter() const
@@ -742,10 +737,10 @@
template<class D, class T> D * get_deleter(shared_ptr<T> const & p)
{
- D *del = detail::basic_get_deleter<D>(p);
+ D *del = detail::basic_get_deleter<D>(p.get_shared_count());
if(del == 0)
{
- detail::sp_deleter_wrapper *del_wrapper = detail::basic_get_deleter<detail::sp_deleter_wrapper>(p);
+ detail::sp_deleter_wrapper *del_wrapper = detail::basic_get_deleter<detail::sp_deleter_wrapper>(p.get_shared_count());
// The following get_deleter method call is fully qualified because
// older versions of gcc (2.95, 3.2.3) fail to compile it when written del_wrapper->get_deleter<D>()
if(del_wrapper) del = del_wrapper->::boost::detail::sp_deleter_wrapper::get_deleter<D>();
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