#ifndef BOOST_SMART_PTR_SHARED_PTR_HPP_INCLUDED #define BOOST_SMART_PTR_SHARED_PTR_HPP_INCLUDED // // shared_ptr.hpp // // (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. // Copyright (c) 2001-2008 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/smart_ptr/shared_ptr.htm for documentation. // #include // for broken compiler workarounds #if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES) #include #else // In order to avoid circular dependencies with Boost.TR1 // we make sure that our include of doesn't try to // pull in the TR1 headers: that's why we use this header // rather than including directly: #include // std::auto_ptr #include #include #include #include #include #include #include #if !defined(BOOST_SP_NO_ATOMIC_ACCESS) #include #include #endif #include // for std::swap #include // for std::less #include // for std::bad_cast #include // for std::size_t #if !defined(BOOST_NO_IOSTREAM) #if !defined(BOOST_NO_IOSFWD) #include // for std::basic_ostream #else #include #endif #endif namespace cutl_details_boost { template class shared_ptr; template class weak_ptr; template class enable_shared_from_this; class enable_shared_from_raw; namespace detail { // sp_element, element_type template< class T > struct sp_element { typedef T type; }; #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template< class T > struct sp_element< T[] > { typedef T type; }; #if !defined( __BORLANDC__ ) || !BOOST_WORKAROUND( __BORLANDC__, < 0x600 ) template< class T, std::size_t N > struct sp_element< T[N] > { typedef T type; }; #endif #endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) // sp_dereference, return type of operator* template< class T > struct sp_dereference { typedef T & type; }; template<> struct sp_dereference< void > { typedef void type; }; #if !defined(BOOST_NO_CV_VOID_SPECIALIZATIONS) template<> struct sp_dereference< void const > { typedef void type; }; template<> struct sp_dereference< void volatile > { typedef void type; }; template<> struct sp_dereference< void const volatile > { typedef void type; }; #endif // !defined(BOOST_NO_CV_VOID_SPECIALIZATIONS) #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template< class T > struct sp_dereference< T[] > { typedef void type; }; #if !defined( __BORLANDC__ ) || !BOOST_WORKAROUND( __BORLANDC__, < 0x600 ) template< class T, std::size_t N > struct sp_dereference< T[N] > { typedef void type; }; #endif #endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) // sp_member_access, return type of operator-> template< class T > struct sp_member_access { typedef T * type; }; #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template< class T > struct sp_member_access< T[] > { typedef void type; }; #if !defined( __BORLANDC__ ) || !BOOST_WORKAROUND( __BORLANDC__, < 0x600 ) template< class T, std::size_t N > struct sp_member_access< T[N] > { typedef void type; }; #endif #endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) // sp_array_access, return type of operator[] template< class T > struct sp_array_access { typedef void type; }; #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template< class T > struct sp_array_access< T[] > { typedef T & type; }; #if !defined( __BORLANDC__ ) || !BOOST_WORKAROUND( __BORLANDC__, < 0x600 ) template< class T, std::size_t N > struct sp_array_access< T[N] > { typedef T & type; }; #endif #endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) // sp_extent, for operator[] index check template< class T > struct sp_extent { enum _vt { value = 0 }; }; #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template< class T, std::size_t N > struct sp_extent< T[N] > { enum _vt { value = N }; }; #endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) // enable_shared_from_this support template< class X, class Y, class T > inline void sp_enable_shared_from_this( cutl_details_boost::shared_ptr const * ppx, Y const * py, cutl_details_boost::enable_shared_from_this< T > const * pe ) { if( pe != 0 ) { pe->_internal_accept_owner( ppx, const_cast< Y* >( py ) ); } } template< class X, class Y > inline void sp_enable_shared_from_this( cutl_details_boost::shared_ptr * ppx, Y const * py, cutl_details_boost::enable_shared_from_raw const * pe ); #ifdef _MANAGED // Avoid C4793, ... causes native code generation struct sp_any_pointer { template sp_any_pointer( T* ) {} }; inline void sp_enable_shared_from_this( sp_any_pointer, sp_any_pointer, sp_any_pointer ) { } #else // _MANAGED inline void sp_enable_shared_from_this( ... ) { } #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 // sp_assert_convertible template< class Y, class T > inline void sp_assert_convertible() { #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) // static_assert( sp_convertible< Y, T >::value ); typedef char tmp[ sp_convertible< Y, T >::value? 1: -1 ]; (void)sizeof( tmp ); #else T* p = static_cast< Y* >( 0 ); (void)p; #endif } // pointer constructor helper template< class T, class Y > inline void sp_pointer_construct( cutl_details_boost::shared_ptr< T > * ppx, Y * p, cutl_details_boost::detail::shared_count & pn ) { cutl_details_boost::detail::shared_count( p ).swap( pn ); cutl_details_boost::detail::sp_enable_shared_from_this( ppx, p, p ); } #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template< class T, class Y > inline void sp_pointer_construct( cutl_details_boost::shared_ptr< T[] > * /*ppx*/, Y * p, cutl_details_boost::detail::shared_count & pn ) { sp_assert_convertible< Y[], T[] >(); cutl_details_boost::detail::shared_count( p, cutl_details_boost::checked_array_deleter< T >() ).swap( pn ); } template< class T, std::size_t N, class Y > inline void sp_pointer_construct( cutl_details_boost::shared_ptr< T[N] > * /*ppx*/, Y * p, cutl_details_boost::detail::shared_count & pn ) { sp_assert_convertible< Y[N], T[N] >(); cutl_details_boost::detail::shared_count( p, cutl_details_boost::checked_array_deleter< T >() ).swap( pn ); } #endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) // deleter constructor helper template< class T, class Y > inline void sp_deleter_construct( cutl_details_boost::shared_ptr< T > * ppx, Y * p ) { cutl_details_boost::detail::sp_enable_shared_from_this( ppx, p, p ); } #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template< class T, class Y > inline void sp_deleter_construct( cutl_details_boost::shared_ptr< T[] > * /*ppx*/, Y * /*p*/ ) { sp_assert_convertible< Y[], T[] >(); } template< class T, std::size_t N, class Y > inline void sp_deleter_construct( cutl_details_boost::shared_ptr< T[N] > * /*ppx*/, Y * /*p*/ ) { sp_assert_convertible< Y[N], T[N] >(); } #endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) } // namespace detail // // shared_ptr // // An enhanced relative of scoped_ptr with reference counted copy semantics. // The object pointed to is deleted when the last shared_ptr pointing to it // is destroyed or reset. // template class shared_ptr { private: // Borland 5.5.1 specific workaround typedef shared_ptr this_type; public: typedef typename cutl_details_boost::detail::sp_element< T >::type element_type; shared_ptr() BOOST_NOEXCEPT : px( 0 ), pn() // never throws in 1.30+ { } #if !defined( BOOST_NO_CXX11_NULLPTR ) shared_ptr( cutl_details_boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT : px( 0 ), pn() // never throws { } #endif template explicit shared_ptr( Y * p ): px( p ), pn() // Y must be complete { cutl_details_boost::detail::sp_pointer_construct( this, p, pn ); } // // Requirements: D's copy constructor must not throw // // shared_ptr will release p by calling d(p) // template shared_ptr( Y * p, D d ): px( p ), pn( p, d ) { cutl_details_boost::detail::sp_deleter_construct( this, p ); } #if !defined( BOOST_NO_CXX11_NULLPTR ) template shared_ptr( cutl_details_boost::detail::sp_nullptr_t p, D d ): px( p ), pn( p, d ) { } #endif // 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 ) { cutl_details_boost::detail::sp_deleter_construct( this, p ); } #if !defined( BOOST_NO_CXX11_NULLPTR ) template shared_ptr( cutl_details_boost::detail::sp_nullptr_t p, D d, A a ): px( p ), pn( p, d, a ) { } #endif // generated copy constructor, destructor are fine... #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) // ... except in C++0x, move disables the implicit copy shared_ptr( shared_ptr const & r ) BOOST_NOEXCEPT : px( r.px ), pn( r.pn ) { } #endif template explicit shared_ptr( weak_ptr const & r ): pn( r.pn ) // may throw { cutl_details_boost::detail::sp_assert_convertible< Y, T >(); // it is now safe to copy r.px, as pn(r.pn) did not throw px = r.px; } template shared_ptr( weak_ptr const & r, cutl_details_boost::detail::sp_nothrow_tag ) BOOST_NOEXCEPT : px( 0 ), pn( r.pn, cutl_details_boost::detail::sp_nothrow_tag() ) { if( !pn.empty() ) { px = r.px; } } template #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) shared_ptr( shared_ptr const & r, typename cutl_details_boost::detail::sp_enable_if_convertible::type = cutl_details_boost::detail::sp_empty() ) #else shared_ptr( shared_ptr const & r ) #endif BOOST_NOEXCEPT : px( r.px ), pn( r.pn ) { cutl_details_boost::detail::sp_assert_convertible< Y, T >(); } // aliasing template< class Y > shared_ptr( shared_ptr const & r, element_type * p ) BOOST_NOEXCEPT : px( p ), pn( r.pn ) { } #ifndef BOOST_NO_AUTO_PTR template explicit shared_ptr( std::auto_ptr & r ): px(r.get()), pn() { cutl_details_boost::detail::sp_assert_convertible< Y, T >(); Y * tmp = r.get(); pn = cutl_details_boost::detail::shared_count( r ); cutl_details_boost::detail::sp_deleter_construct( this, tmp ); } #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) template shared_ptr( std::auto_ptr && r ): px(r.get()), pn() { cutl_details_boost::detail::sp_assert_convertible< Y, T >(); Y * tmp = r.get(); pn = cutl_details_boost::detail::shared_count( r ); cutl_details_boost::detail::sp_deleter_construct( this, tmp ); } #elif !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template explicit shared_ptr( Ap r, typename cutl_details_boost::detail::sp_enable_if_auto_ptr::type = 0 ): px( r.get() ), pn() { typedef typename Ap::element_type Y; cutl_details_boost::detail::sp_assert_convertible< Y, T >(); Y * tmp = r.get(); pn = cutl_details_boost::detail::shared_count( r ); cutl_details_boost::detail::sp_deleter_construct( this, tmp ); } #endif // BOOST_NO_SFINAE, BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION #endif // BOOST_NO_AUTO_PTR #if !defined( BOOST_NO_CXX11_SMART_PTR ) && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) template< class Y, class D > shared_ptr( std::unique_ptr< Y, D > && r ): px( r.get() ), pn() { cutl_details_boost::detail::sp_assert_convertible< Y, T >(); typename std::unique_ptr< Y, D >::pointer tmp = r.get(); pn = cutl_details_boost::detail::shared_count( r ); cutl_details_boost::detail::sp_deleter_construct( this, tmp ); } #endif // assignment shared_ptr & operator=( shared_ptr const & r ) BOOST_NOEXCEPT { this_type(r).swap(*this); return *this; } #if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1400) template shared_ptr & operator=(shared_ptr const & r) BOOST_NOEXCEPT { this_type(r).swap(*this); return *this; } #endif #ifndef BOOST_NO_AUTO_PTR template shared_ptr & operator=( std::auto_ptr & r ) { this_type( r ).swap( *this ); return *this; } #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) template shared_ptr & operator=( std::auto_ptr && r ) { this_type( static_cast< std::auto_ptr && >( r ) ).swap( *this ); return *this; } #elif !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) template typename cutl_details_boost::detail::sp_enable_if_auto_ptr< Ap, shared_ptr & >::type operator=( Ap r ) { this_type( r ).swap( *this ); return *this; } #endif // BOOST_NO_SFINAE, BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION #endif // BOOST_NO_AUTO_PTR #if !defined( BOOST_NO_CXX11_SMART_PTR ) && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) template shared_ptr & operator=( std::unique_ptr && r ) { this_type( static_cast< std::unique_ptr && >( r ) ).swap(*this); return *this; } #endif // Move support #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) shared_ptr( shared_ptr && r ) BOOST_NOEXCEPT : px( r.px ), pn() { pn.swap( r.pn ); r.px = 0; } template #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) shared_ptr( shared_ptr && r, typename cutl_details_boost::detail::sp_enable_if_convertible::type = cutl_details_boost::detail::sp_empty() ) #else shared_ptr( shared_ptr && r ) #endif BOOST_NOEXCEPT : px( r.px ), pn() { cutl_details_boost::detail::sp_assert_convertible< Y, T >(); pn.swap( r.pn ); r.px = 0; } shared_ptr & operator=( shared_ptr && r ) BOOST_NOEXCEPT { this_type( static_cast< shared_ptr && >( r ) ).swap( *this ); return *this; } template shared_ptr & operator=( shared_ptr && r ) BOOST_NOEXCEPT { this_type( static_cast< shared_ptr && >( r ) ).swap( *this ); return *this; } #endif #if !defined( BOOST_NO_CXX11_NULLPTR ) shared_ptr & operator=( cutl_details_boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT // never throws { this_type().swap(*this); return *this; } #endif void reset() BOOST_NOEXCEPT // never throws in 1.30+ { this_type().swap(*this); } template void reset( Y * p ) // Y must be complete { BOOST_ASSERT( p == 0 || p != px ); // catch self-reset errors this_type( p ).swap( *this ); } template void reset( Y * p, D d ) { this_type( p, d ).swap( *this ); } template void reset( Y * p, D d, A a ) { this_type( p, d, a ).swap( *this ); } template void reset( shared_ptr const & r, element_type * p ) { this_type( r, p ).swap( *this ); } // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT) typename cutl_details_boost::detail::sp_dereference< T >::type operator* () const { BOOST_ASSERT( px != 0 ); return *px; } // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT) typename cutl_details_boost::detail::sp_member_access< T >::type operator-> () const { BOOST_ASSERT( px != 0 ); return px; } // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT) typename cutl_details_boost::detail::sp_array_access< T >::type operator[] ( std::ptrdiff_t i ) const { BOOST_ASSERT( px != 0 ); BOOST_ASSERT( i >= 0 && ( i < cutl_details_boost::detail::sp_extent< T >::value || cutl_details_boost::detail::sp_extent< T >::value == 0 ) ); return px[ i ]; } element_type * get() const BOOST_NOEXCEPT { return px; } // implicit conversion to "bool" #include bool unique() const BOOST_NOEXCEPT { return pn.unique(); } long use_count() const BOOST_NOEXCEPT { return pn.use_count(); } void swap( shared_ptr & other ) BOOST_NOEXCEPT { std::swap(px, other.px); pn.swap(other.pn); } template bool owner_before( shared_ptr const & rhs ) const BOOST_NOEXCEPT { return pn < rhs.pn; } template bool owner_before( weak_ptr const & rhs ) const BOOST_NOEXCEPT { return pn < rhs.pn; } void * _internal_get_deleter( cutl_details_boost::detail::sp_typeinfo const & ti ) const BOOST_NOEXCEPT { return pn.get_deleter( ti ); } void * _internal_get_untyped_deleter() const BOOST_NOEXCEPT { return pn.get_untyped_deleter(); } bool _internal_equiv( shared_ptr const & r ) const BOOST_NOEXCEPT { return px == r.px && pn == r.pn; } // Tasteless as this may seem, making all members public allows member templates // to work in the absence of member template friends. (Matthew Langston) #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS private: template friend class shared_ptr; template friend class weak_ptr; #endif element_type * px; // contained pointer cutl_details_boost::detail::shared_count pn; // reference counter }; // shared_ptr template inline bool operator==(shared_ptr const & a, shared_ptr const & b) BOOST_NOEXCEPT { return a.get() == b.get(); } template inline bool operator!=(shared_ptr const & a, shared_ptr const & b) BOOST_NOEXCEPT { return a.get() != b.get(); } #if __GNUC__ == 2 && __GNUC_MINOR__ <= 96 // Resolve the ambiguity between our op!= and the one in rel_ops template inline bool operator!=(shared_ptr const & a, shared_ptr const & b) BOOST_NOEXCEPT { return a.get() != b.get(); } #endif #if !defined( BOOST_NO_CXX11_NULLPTR ) template inline bool operator==( shared_ptr const & p, cutl_details_boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT { return p.get() == 0; } template inline bool operator==( cutl_details_boost::detail::sp_nullptr_t, shared_ptr const & p ) BOOST_NOEXCEPT { return p.get() == 0; } template inline bool operator!=( shared_ptr const & p, cutl_details_boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT { return p.get() != 0; } template inline bool operator!=( cutl_details_boost::detail::sp_nullptr_t, shared_ptr const & p ) BOOST_NOEXCEPT { return p.get() != 0; } #endif template inline bool operator<(shared_ptr const & a, shared_ptr const & b) BOOST_NOEXCEPT { return a.owner_before( b ); } template inline void swap(shared_ptr & a, shared_ptr & b) BOOST_NOEXCEPT { a.swap(b); } template shared_ptr static_pointer_cast( shared_ptr const & r ) BOOST_NOEXCEPT { (void) static_cast< T* >( static_cast< U* >( 0 ) ); typedef typename shared_ptr::element_type E; E * p = static_cast< E* >( r.get() ); return shared_ptr( r, p ); } template shared_ptr const_pointer_cast( shared_ptr const & r ) BOOST_NOEXCEPT { (void) const_cast< T* >( static_cast< U* >( 0 ) ); typedef typename shared_ptr::element_type E; E * p = const_cast< E* >( r.get() ); return shared_ptr( r, p ); } template shared_ptr dynamic_pointer_cast( shared_ptr const & r ) BOOST_NOEXCEPT { (void) dynamic_cast< T* >( static_cast< U* >( 0 ) ); typedef typename shared_ptr::element_type E; E * p = dynamic_cast< E* >( r.get() ); return p? shared_ptr( r, p ): shared_ptr(); } template shared_ptr reinterpret_pointer_cast( shared_ptr const & r ) BOOST_NOEXCEPT { (void) reinterpret_cast< T* >( static_cast< U* >( 0 ) ); typedef typename shared_ptr::element_type E; E * p = reinterpret_cast< E* >( r.get() ); return shared_ptr( r, p ); } // get_pointer() enables cutl_details_boost::mem_fn to recognize shared_ptr template inline typename shared_ptr::element_type * get_pointer(shared_ptr const & p) BOOST_NOEXCEPT { return p.get(); } // operator<< #if !defined(BOOST_NO_IOSTREAM) #if defined(BOOST_NO_TEMPLATED_IOSTREAMS) || ( defined(__GNUC__) && (__GNUC__ < 3) ) template std::ostream & operator<< (std::ostream & os, shared_ptr const & p) { os << p.get(); return os; } #else // in STLport's no-iostreams mode no iostream symbols can be used #ifndef _STLP_NO_IOSTREAMS # if defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, < 1300 && __SGI_STL_PORT) // MSVC6 has problems finding std::basic_ostream through the using declaration in namespace _STL using std::basic_ostream; template basic_ostream & operator<< (basic_ostream & os, shared_ptr const & p) # else template std::basic_ostream & operator<< (std::basic_ostream & os, shared_ptr const & p) # endif { os << p.get(); return os; } #endif // _STLP_NO_IOSTREAMS #endif // __GNUC__ < 3 #endif // !defined(BOOST_NO_IOSTREAM) // get_deleter namespace detail { #if ( defined(__GNUC__) && BOOST_WORKAROUND(__GNUC__, < 3) ) || \ ( defined(__EDG_VERSION__) && BOOST_WORKAROUND(__EDG_VERSION__, <= 238) ) || \ ( defined(__HP_aCC) && BOOST_WORKAROUND(__HP_aCC, <= 33500) ) // g++ 2.9x doesn't allow static_cast(void *) // apparently EDG 2.38 and HP aCC A.03.35 also don't accept it template D * basic_get_deleter(shared_ptr const & p) { void const * q = p._internal_get_deleter(BOOST_SP_TYPEID(D)); return const_cast(static_cast(q)); } #else template D * basic_get_deleter( shared_ptr const & p ) BOOST_NOEXCEPT { return static_cast( p._internal_get_deleter(BOOST_SP_TYPEID(D)) ); } #endif class esft2_deleter_wrapper { private: shared_ptr deleter_; public: esft2_deleter_wrapper() { } template< class T > void set_deleter( shared_ptr const & deleter ) { deleter_ = deleter; } template D* get_deleter() const BOOST_NOEXCEPT { return cutl_details_boost::detail::basic_get_deleter( deleter_ ); } template< class T> void operator()( T* ) { BOOST_ASSERT( deleter_.use_count() <= 1 ); deleter_.reset(); } }; } // namespace detail template D * get_deleter( shared_ptr const & p ) BOOST_NOEXCEPT { D *del = cutl_details_boost::detail::basic_get_deleter(p); if(del == 0) { cutl_details_boost::detail::esft2_deleter_wrapper *del_wrapper = cutl_details_boost::detail::basic_get_deleter(p); // 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() if(del_wrapper) del = del_wrapper->::cutl_details_boost::detail::esft2_deleter_wrapper::get_deleter(); } return del; } // atomic access #if !defined(BOOST_SP_NO_ATOMIC_ACCESS) template inline bool atomic_is_lock_free( shared_ptr const * /*p*/ ) BOOST_NOEXCEPT { return false; } template shared_ptr atomic_load( shared_ptr const * p ) { cutl_details_boost::detail::spinlock_pool<2>::scoped_lock lock( p ); return *p; } template inline shared_ptr atomic_load_explicit( shared_ptr const * p, memory_order /*mo*/ ) { return atomic_load( p ); } template void atomic_store( shared_ptr * p, shared_ptr r ) { cutl_details_boost::detail::spinlock_pool<2>::scoped_lock lock( p ); p->swap( r ); } template inline void atomic_store_explicit( shared_ptr * p, shared_ptr r, memory_order /*mo*/ ) { atomic_store( p, r ); // std::move( r ) } template shared_ptr atomic_exchange( shared_ptr * p, shared_ptr r ) { cutl_details_boost::detail::spinlock & sp = cutl_details_boost::detail::spinlock_pool<2>::spinlock_for( p ); sp.lock(); p->swap( r ); sp.unlock(); return r; // return std::move( r ) } template shared_ptr atomic_exchange_explicit( shared_ptr * p, shared_ptr r, memory_order /*mo*/ ) { return atomic_exchange( p, r ); // std::move( r ) } template bool atomic_compare_exchange( shared_ptr * p, shared_ptr * v, shared_ptr w ) { cutl_details_boost::detail::spinlock & sp = cutl_details_boost::detail::spinlock_pool<2>::spinlock_for( p ); sp.lock(); if( p->_internal_equiv( *v ) ) { p->swap( w ); sp.unlock(); return true; } else { shared_ptr tmp( *p ); sp.unlock(); tmp.swap( *v ); return false; } } template inline bool atomic_compare_exchange_explicit( shared_ptr * p, shared_ptr * v, shared_ptr w, memory_order /*success*/, memory_order /*failure*/ ) { return atomic_compare_exchange( p, v, w ); // std::move( w ) } #endif // !defined(BOOST_SP_NO_ATOMIC_ACCESS) // hash_value template< class T > struct hash; template< class T > std::size_t hash_value( cutl_details_boost::shared_ptr const & p ) BOOST_NOEXCEPT { return cutl_details_boost::hash< T* >()( p.get() ); } } // namespace cutl_details_boost #endif // #if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES) #endif // #ifndef BOOST_SMART_PTR_SHARED_PTR_HPP_INCLUDED