Index: boost/enable_shared_from_this.hpp
===================================================================
--- boost/enable_shared_from_this.hpp	(revision 44887)
+++ boost/enable_shared_from_this.hpp	(working copy)
@@ -13,6 +13,7 @@
 //  http://www.boost.org/libs/smart_ptr/enable_shared_from_this.html
 //
 
+#include <boost/weak_ptr.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/assert.hpp>
 #include <boost/config.hpp>
@@ -44,7 +45,7 @@
 // virtual destructor because we need a vtable for dynamic_cast from base to derived to work
     virtual ~enable_shared_from_this()
     {
-        BOOST_ASSERT( _shared_count.use_count() <= 1 ); // make sure no dangling shared_ptr objects exist
+        BOOST_ASSERT( _shared_ptr.use_count() <= 1 ); // make sure no dangling shared_ptr objects exist
     }
 
 public:
@@ -52,46 +53,52 @@
     shared_ptr<T> shared_from_this()
     {
         init_weak_once();
-        T * p = dynamic_cast<T *>( this );
-        return shared_ptr<T>( detail::shared_count( _weak_count ), p );
+        shared_ptr<T> p( _weak_ptr );
+        BOOST_ASSERT( p.get() == this );
+        return p;
     }
 
     shared_ptr<T const> shared_from_this() const
     {
         init_weak_once();
-        T const * p = dynamic_cast<T const *>( this );
-        return shared_ptr<T const>( detail::shared_count( _weak_count ), p );
+        shared_ptr<T const> p( _weak_ptr );
+        BOOST_ASSERT( p.get() == this );
+        return p;
     }
 
 private:
 
-    mutable detail::weak_count _weak_count;
-    mutable detail::shared_count _shared_count;
+    typedef T _internal_element_type; // for bcc 5.5.1
+    mutable weak_ptr<_internal_element_type> _weak_ptr;
+    mutable shared_ptr<_internal_element_type> _shared_ptr;
 
     void init_weak_once() const
     {
-        if( _weak_count.empty() )
+        if( !_weak_ptr )
         {
-            detail::shared_count( (void*)0, detail::sp_deleter_wrapper() ).swap( _shared_count );
-            _weak_count = _shared_count;
+            T * p = dynamic_cast<T *>( const_cast<enable_shared_from_this*>( this ) );
+            _shared_ptr.reset( p, detail::sp_deleter_wrapper() );
+            BOOST_ASSERT( _shared_ptr.get() == p );
+            _weak_ptr = _shared_ptr;
         }
     }
 
     template<typename U>
     void sp_accept_owner( shared_ptr<U> & owner ) const
     {
-        if( _weak_count.use_count() == 0 )
+        if( _weak_ptr.use_count() == 0 )
         {
-            _weak_count = owner.get_shared_count();
-        }else if( !_shared_count.empty() )
+            T * p = dynamic_cast<T *>( const_cast<enable_shared_from_this*>( this ) );
+            _weak_ptr = shared_ptr<T>( owner, p );
+        }else if( _shared_ptr )
         {
             BOOST_ASSERT( owner.unique() ); // no weak_ptrs to owner should exist either, but there's no way to check that
-            detail::sp_deleter_wrapper * pd = detail::basic_get_deleter<detail::sp_deleter_wrapper>( _shared_count );
+            detail::sp_deleter_wrapper * pd = get_deleter<detail::sp_deleter_wrapper>( _shared_ptr );
             BOOST_ASSERT( pd != 0 );
-            pd->set_deleter( owner.get_shared_count() );
+            pd->set_deleter( owner );
 
-            owner.reset( _shared_count, owner.get() );
-            detail::shared_count().swap( _shared_count );
+            owner.reset( _shared_ptr, owner.get() );
+            _shared_ptr.reset();
         }
     }
 
Index: boost/weak_ptr.hpp
===================================================================
--- boost/weak_ptr.hpp	(revision 44887)
+++ boost/weak_ptr.hpp	(working copy)
@@ -96,6 +96,58 @@
         return shared_ptr<element_type>( *this, boost::detail::sp_nothrow_tag() );
     }
 
+    // implicit conversion to "bool"
+
+#if ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570) ) || defined(__CINT__)
+
+    operator bool () const
+    {
+        return px != 0;
+    }
+
+#elif defined( _MANAGED )
+
+    static void unspecified_bool( this_type*** )
+    {
+    }
+
+    typedef void (*unspecified_bool_type)( this_type*** );
+
+    operator unspecified_bool_type() const // never throws
+    {
+        return px == 0? 0: unspecified_bool;
+    }
+
+#elif \
+    ( defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, < 0x3200) ) || \
+    ( defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304) ) || \
+    ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) )
+
+    typedef T * (this_type::*unspecified_bool_type)() const;
+
+    operator unspecified_bool_type() const // never throws
+    {
+        return px == 0? 0: &this_type::get;
+    }
+
+#else
+
+    typedef T * this_type::*unspecified_bool_type;
+
+    operator unspecified_bool_type() const // never throws
+    {
+        return px == 0? 0: &this_type::px;
+    }
+
+#endif
+
+    // operator! is redundant, but some compilers need it
+
+    bool operator! () const // never throws
+    {
+        return px == 0;
+    }
+
     long use_count() const // never throws
     {
         return pn.use_count();
@@ -117,12 +169,6 @@
         pn.swap(other.pn);
     }
 
-    void _internal_assign(T * px2, boost::detail::shared_count const & pn2)
-    {
-        px = px2;
-        pn = pn2;
-    }
-
     template<class Y> bool _internal_less(weak_ptr<Y> const & rhs) const
     {
         return pn < rhs.pn;
Index: boost/shared_ptr.hpp
===================================================================
--- boost/shared_ptr.hpp	(revision 44887)
+++ boost/shared_ptr.hpp	(working copy)
@@ -721,6 +721,10 @@
     {
         _deleter = deleter;
     }
+    void set_deleter(shared_ptr<void const> const &deleter)
+    {
+        _deleter = deleter.get_shared_count();
+    }
     void operator()(const void *)
     {
         BOOST_ASSERT(_deleter.use_count() <= 1);