Index: boost/enable_shared_from_this.hpp =================================================================== --- boost/enable_shared_from_this.hpp (revision 44152) +++ boost/enable_shared_from_this.hpp (working copy) @@ -109,6 +109,15 @@ } }; +// register enable_shared_from_this as an observer +template void sp_notify_observer( shared_ptr * ptr, enable_shared_from_this const * pe ) +{ + if(pe != 0) + { + pe->_internal_accept_owner(*ptr); + } +} + } // namespace boost #endif // #ifndef BOOST_ENABLE_SHARED_FROM_THIS_HPP_INCLUDED Index: boost/shared_ptr.hpp =================================================================== --- boost/shared_ptr.hpp (revision 44152) +++ boost/shared_ptr.hpp (working copy) @@ -50,7 +50,6 @@ template class shared_ptr; template class weak_ptr; -template class enable_shared_from_this; namespace detail { @@ -93,35 +92,50 @@ struct ignore_enable_shared_from_this_tag {}; -template void sp_enable_shared_from_this( boost::shared_ptr * ptr, boost::enable_shared_from_this const * pe ) + +#if !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) && !defined( BOOST_NO_AUTO_PTR ) + +// rvalue auto_ptr support based on a technique by Dave Abrahams + +template< class T, class R > struct sp_enable_if_auto_ptr { - if(pe != 0) - { - pe->_internal_accept_owner(*ptr); - } -} +}; +template< class T, class R > struct sp_enable_if_auto_ptr< std::auto_ptr< T >, R > +{ + typedef R type; +}; + +#endif + +} // namespace detail + #ifdef _MANAGED // Avoid C4793, ... causes native code generation +namespace detail +{ + struct sp_any_pointer { template sp_any_pointer( T* ) {} }; -inline void sp_enable_shared_from_this( sp_any_pointer, sp_any_pointer ) +} // namespace detail + +inline void sp_notify_observer( detail::sp_any_pointer, detail::sp_any_pointer ) { } #else // _MANAGED #ifdef sgi -// Turn off: the last argument of the varargs function "sp_enable_shared_from_this" is unnamed +// Turn off: the last argument of the varargs function "sp_notify_observer" is unnamed # pragma set woff 3506 #endif -inline void sp_enable_shared_from_this( ... ) +inline void sp_notify_observer( ... ) { } @@ -131,24 +145,6 @@ #endif // _MANAGED -#if !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) && !defined( BOOST_NO_AUTO_PTR ) - -// rvalue auto_ptr support based on a technique by Dave Abrahams - -template< class T, class R > struct sp_enable_if_auto_ptr -{ -}; - -template< class T, class R > struct sp_enable_if_auto_ptr< std::auto_ptr< T >, R > -{ - typedef R type; -}; - -#endif - -} // namespace detail - - // // shared_ptr // @@ -178,7 +174,7 @@ template explicit shared_ptr( Y * p ): px( p ), pn( p ) // Y must be complete { - boost::detail::sp_enable_shared_from_this( this, p ); + sp_notify_observer( this, p ); } // @@ -189,14 +185,14 @@ template shared_ptr(Y * p, D d): px(p), pn(p, d) { - boost::detail::sp_enable_shared_from_this( this, p ); + sp_notify_observer( this, p ); } // As above, but with allocator. A's copy constructor shall not throw. template shared_ptr( Y * p, D d, A a ): px( p ), pn( p, d, a ) { - boost::detail::sp_enable_shared_from_this( this, p ); + sp_notify_observer( this, p ); } // generated copy constructor, assignment, destructor are fine... @@ -272,7 +268,7 @@ { Y * tmp = r.get(); pn = boost::detail::shared_count(r); - boost::detail::sp_enable_shared_from_this( this, tmp ); + sp_notify_observer( this, tmp ); } #if !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) @@ -282,7 +278,7 @@ { typename Ap::element_type * tmp = r.get(); pn = boost::detail::shared_count( r ); - boost::detail::sp_enable_shared_from_this( this, tmp ); + sp_notify_observer( this, tmp ); }