1 #ifndef BOOST_SMART_PTR_SHARED_PTR_HPP_INCLUDED 2 #define BOOST_SMART_PTR_SHARED_PTR_HPP_INCLUDED 19 #if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES) 20 #include <boost/smart_ptr/detail/shared_ptr_nmt.hpp> 37 #if !defined(BOOST_SP_NO_ATOMIC_ACCESS) 47 #if !defined(BOOST_NO_IOSTREAM) 48 #if !defined(BOOST_NO_IOSFWD) 58 template<
class T>
class shared_ptr;
61 class enable_shared_from_raw;
73 #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) 80 #if !defined( __BORLANDC__ ) || !BOOST_WORKAROUND( __BORLANDC__, < 0x600 ) 82 template<
class T, std::
size_t N >
struct sp_element< T[N] >
89 #endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) 103 #if !defined(BOOST_NO_CV_VOID_SPECIALIZATIONS) 120 #endif // !defined(BOOST_NO_CV_VOID_SPECIALIZATIONS) 122 #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) 129 #if !defined( __BORLANDC__ ) || !BOOST_WORKAROUND( __BORLANDC__, < 0x600 ) 138 #endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) 147 #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) 154 #if !defined( __BORLANDC__ ) || !BOOST_WORKAROUND( __BORLANDC__, < 0x600 ) 163 #endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) 172 #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) 179 #if !defined( __BORLANDC__ ) || !BOOST_WORKAROUND( __BORLANDC__, < 0x600 ) 188 #endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) 197 #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) 199 template<
class T, std::
size_t N >
struct sp_extent< T[N] >
204 #endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) 222 struct sp_any_pointer
224 template<
class T> sp_any_pointer( T* ) {}
239 #if !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) && !defined( BOOST_NO_AUTO_PTR ) 258 #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) 266 T* p =
static_cast< Y*
>( 0 );
280 #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) 284 sp_assert_convertible< Y[], T[] >();
290 sp_assert_convertible< Y[N], T[N] >();
294 #endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) 303 #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) 307 sp_assert_convertible< Y[], T[] >();
312 sp_assert_convertible< Y[N], T[N] >();
315 #endif // !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) 343 #if !defined( BOOST_NO_CXX11_NULLPTR ) 363 template<
class Y,
class D>
shared_ptr( Y * p, D d ): px( p ), pn( p, d )
368 #if !defined( BOOST_NO_CXX11_NULLPTR ) 378 template<
class Y,
class D,
class A>
shared_ptr( Y * p, D d, A a ): px( p ), pn( p, d, a )
383 #if !defined( BOOST_NO_CXX11_NULLPTR ) 393 #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) 406 boost::detail::sp_assert_convertible< Y, T >();
423 #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) 434 boost::detail::sp_assert_convertible< Y, T >();
443 #ifndef BOOST_NO_AUTO_PTR 448 boost::detail::sp_assert_convertible< Y, T >();
456 #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) 461 boost::detail::sp_assert_convertible< Y, T >();
469 #elif !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) 476 boost::detail::sp_assert_convertible< Y, T >();
484 #endif // BOOST_NO_SFINAE, BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION 486 #endif // BOOST_NO_AUTO_PTR 488 #if !defined( BOOST_NO_CXX11_SMART_PTR ) 490 template<
class Y,
class D >
493 boost::detail::sp_assert_convertible< Y, T >();
495 typename std::unique_ptr< Y, D >::pointer tmp = r.get();
507 this_type(r).swap(*
this);
511 #if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1400) 516 this_type(r).swap(*
this);
522 #ifndef BOOST_NO_AUTO_PTR 527 this_type( r ).
swap( *
this );
531 #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) 536 this_type(
static_cast< std::auto_ptr<Y> &&
>( r ) ).
swap( *
this );
540 #elif !defined( BOOST_NO_SFINAE ) && !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) 545 this_type( r ).swap( *
this );
549 #endif // BOOST_NO_SFINAE, BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION 551 #endif // BOOST_NO_AUTO_PTR 553 #if !defined( BOOST_NO_CXX11_SMART_PTR ) 555 template<
class Y,
class D>
558 this_type(
static_cast< std::unique_ptr<Y, D> &&
>( r ) ).
swap(*
this);
566 #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) 575 #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) 586 boost::detail::sp_assert_convertible< Y, T >();
594 this_type( static_cast< shared_ptr && >( r ) ).swap( *
this );
601 this_type(
static_cast< shared_ptr<Y> &&
>( r ) ).swap( *
this );
607 #if !defined( BOOST_NO_CXX11_NULLPTR ) 611 this_type().swap(*
this);
619 this_type().swap(*
this);
622 template<
class Y>
void reset( Y * p )
625 this_type( p ).swap( *
this );
628 template<
class Y,
class D>
void reset( Y * p, D d )
630 this_type( p, d ).swap( *
this );
633 template<
class Y,
class D,
class A>
void reset( Y * p, D d, A a )
635 this_type( p, d, a ).swap( *
this );
640 this_type( r, p ).swap( *
this );
681 return pn.use_count();
702 return pn.get_deleter(
ti );
707 return pn.get_untyped_deleter();
712 return px == r.px && pn == r.pn;
718 #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS 735 return a.get() == b.get();
740 return a.get() != b.get();
743 #if __GNUC__ == 2 && __GNUC_MINOR__ <= 96 749 return a.
get() != b.
get();
754 #if !defined( BOOST_NO_CXX11_NULLPTR ) 780 return a.owner_before( b );
790 (void) static_cast< T* >( static_cast< U* >( 0 ) );
794 E * p =
static_cast< E*
>( r.get() );
800 (void) const_cast< T* >( static_cast< U* >( 0 ) );
804 E * p =
const_cast< E*
>( r.get() );
810 (void) dynamic_cast< T* >( static_cast< U* >( 0 ) );
814 E * p =
dynamic_cast< E*
>( r.get() );
820 (void) reinterpret_cast< T* >( static_cast< U* >( 0 ) );
824 E * p =
reinterpret_cast< E*
>( r.get() );
837 #if !defined(BOOST_NO_IOSTREAM) 839 #if defined(BOOST_NO_TEMPLATED_IOSTREAMS) || ( defined(__GNUC__) && (__GNUC__ < 3) ) 841 template<
class Y> std::ostream & operator<< (std::ostream & os, shared_ptr<Y>
const & p)
850 #ifndef _STLP_NO_IOSTREAMS 852 # if defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, < 1300 && __SGI_STL_PORT) 854 using std::basic_ostream;
855 template<
class E,
class T,
class Y> basic_ostream<E, T> & operator<< (basic_ostream<E, T> & os,
shared_ptr<Y> const & p)
857 template<class E, class T, class Y> std::basic_ostream<E, T> &
operator<< (std::basic_ostream<E, T> & os,
shared_ptr<Y> const & p)
864 #endif // _STLP_NO_IOSTREAMS 866 #endif // __GNUC__ < 3 868 #endif // !defined(BOOST_NO_IOSTREAM) 875 #if ( defined(__GNUC__) && BOOST_WORKAROUND(__GNUC__, < 3) ) || \ 876 ( defined(__EDG_VERSION__) && BOOST_WORKAROUND(__EDG_VERSION__, <= 238) ) || \ 877 ( defined(__HP_aCC) && BOOST_WORKAROUND(__HP_aCC, <= 33500) ) 885 return const_cast<D *
>(
static_cast<D
const *
>(q));
916 return boost::detail::basic_get_deleter<D>( deleter_ );
930 D *del = boost::detail::basic_get_deleter<D>(p);
937 if(del_wrapper) del = del_wrapper->::boost::detail::esft2_deleter_wrapper::get_deleter<D>();
945 #if !defined(BOOST_SP_NO_ATOMIC_ACCESS) 1020 #endif // !defined(BOOST_SP_NO_ATOMIC_ACCESS) 1033 #endif // #if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES) 1035 #endif // #ifndef BOOST_SMART_PTR_SHARED_PTR_HPP_INCLUDED std::nullptr_t sp_nullptr_t
bool owner_before(shared_ptr< Y > const &rhs) const BOOST_NOEXCEPT
void sp_assert_convertible()
long use_count() const BOOST_NOEXCEPT
shared_ptr & operator=(shared_ptr const &r) BOOST_NOEXCEPT
D * basic_get_deleter(shared_ptr< T > const &p) BOOST_NOEXCEPT
void * _internal_get_deleter(boost::detail::sp_typeinfo const &ti) const BOOST_NOEXCEPT
shared_ptr(shared_ptr &&r) BOOST_NOEXCEPT
shared_ptr(Y *p, D d, A a)
bool owner_before(weak_ptr< Y > const &rhs) const BOOST_NOEXCEPT
shared_ptr & operator=(std::auto_ptr< Y > &&r)
shared_ptr< T > reinterpret_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
bool atomic_is_lock_free(shared_ptr< T > const *) BOOST_NOEXCEPT
void atomic_store(shared_ptr< T > *p, shared_ptr< T > r)
shared_ptr(shared_ptr< Y > const &r, element_type *p) BOOST_NOEXCEPT
shared_ptr< T > static_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
shared_ptr(std::unique_ptr< Y, D > &&r)
void sp_deleter_construct(boost::shared_ptr< T > *ppx, Y *p)
D * get_deleter(shared_ptr< T > const &p) BOOST_NOEXCEPT
shared_ptr(std::auto_ptr< Y > &&r)
shared_ptr() BOOST_NOEXCEPT
shared_ptr< T >::element_type * get_pointer(shared_ptr< T > const &p) BOOST_NOEXCEPT
void reset(shared_ptr< Y > const &r, element_type *p)
shared_ptr< T > atomic_load_explicit(shared_ptr< T > const *p, memory_order)
void set_deleter(shared_ptr< T > const &deleter)
shared_ptr & operator=(shared_ptr< Y > const &r) BOOST_NOEXCEPT
shared_ptr(boost::detail::sp_nullptr_t) BOOST_NOEXCEPT
bool operator==(shared_ptr< T > const &a, shared_ptr< U > const &b) BOOST_NOEXCEPT
D * get_deleter() const BOOST_NOEXCEPT
shared_ptr(shared_ptr< Y > &&r, typename boost::detail::sp_enable_if_convertible< Y, T >::type=boost::detail::sp_empty()) BOOST_NOEXCEPT
element_type * get() const BOOST_NOEXCEPT
void swap(shared_ptr &other) BOOST_NOEXCEPT
shared_ptr & operator=(shared_ptr< Y > &&r) BOOST_NOEXCEPT
shared_ptr(boost::detail::sp_nullptr_t p, D d)
void * _internal_get_untyped_deleter() const BOOST_NOEXCEPT
shared_ptr(weak_ptr< Y > const &r)
#define BOOST_SP_TYPEID(T)
bool unique() const BOOST_NOEXCEPT
void sp_pointer_construct(boost::shared_ptr< T > *ppx, Y *p, boost::detail::shared_count &pn)
void sp_enable_shared_from_this(boost::shared_ptr< X > const *ppx, Y const *py, boost::enable_shared_from_this< T > const *pe)
bool atomic_compare_exchange(shared_ptr< T > *p, shared_ptr< T > *v, shared_ptr< T > w)
void swap(shared_count &r)
shared_ptr & operator=(boost::detail::sp_nullptr_t) BOOST_NOEXCEPT
shared_ptr & operator=(std::auto_ptr< Y > &r)
shared_ptr(shared_ptr const &r) BOOST_NOEXCEPT
std::size_t hash_value(boost::shared_ptr< T > const &p) BOOST_NOEXCEPT
shared_ptr(std::auto_ptr< Y > &r)
shared_ptr(shared_ptr< Y > const &r, typename boost::detail::sp_enable_if_convertible< Y, T >::type=boost::detail::sp_empty()) BOOST_NOEXCEPT
void swap(shared_ptr< T > &a, shared_ptr< T > &b) BOOST_NOEXCEPT
shared_ptr & operator=(std::unique_ptr< Y, D > &&r)
std::type_info sp_typeinfo
shared_ptr(weak_ptr< Y > const &r, boost::detail::sp_nothrow_tag) BOOST_NOEXCEPT
void atomic_store_explicit(shared_ptr< T > *p, shared_ptr< T > r, memory_order)
shared_ptr & operator=(shared_ptr &&r) BOOST_NOEXCEPT
void _internal_accept_owner(shared_ptr< X > const *ppx, Y *py) const
shared_ptr< T > dynamic_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
bool atomic_compare_exchange_explicit(shared_ptr< T > *p, shared_ptr< T > *v, shared_ptr< T > w, memory_order, memory_order)
bool _internal_equiv(shared_ptr const &r) const BOOST_NOEXCEPT
static spinlock & spinlock_for(void const *pv)
#define BOOST_ASSERT(expr)
shared_ptr< T > atomic_load(shared_ptr< T > const *p)
shared_ptr< T > const_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
void reset(Y *p, D d, A a)
shared_ptr< T > atomic_exchange(shared_ptr< T > *p, shared_ptr< T > r)
bool operator!=(shared_ptr< T > const &a, shared_ptr< U > const &b) BOOST_NOEXCEPT
shared_ptr(boost::detail::sp_nullptr_t p, D d, A a)
shared_ptr< T > atomic_exchange_explicit(shared_ptr< T > *p, shared_ptr< T > r, memory_order)
void reset() BOOST_NOEXCEPT
boost::detail::sp_element< T >::type element_type