1 #define DEBUG_SHARED_PTR
2 #ifndef DEBUG_SHARED_PTR
4 #include <boost/shared_ptr.hpp>
10 #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
11 #define BOOST_SHARED_PTR_HPP_INCLUDED
28 #include <boost/config.hpp>
30 #if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES)
31 #include <boost/detail/shared_ptr_nmt.hpp>
34 #include <boost/assert.hpp>
35 #include <boost/checked_delete.hpp>
36 #include <boost/throw_exception.hpp>
37 #include <boost/detail/shared_count.hpp>
38 #include <boost/detail/workaround.hpp>
46 #ifdef BOOST_MSVC // moved here to work around VC++ compiler crash
47 # pragma warning(push)
48 # pragma warning(disable:4284) // odd return type for operator->
75 #if !defined(BOOST_NO_CV_VOID_SPECIALIZATIONS)
98 if(pe != 0) pe->_internal_weak_this._internal_assign(const_cast<Y*>(px), pn);
154 #if defined(__BORLANDC__) || defined(__GNUC__)
192 pn = detail::shared_count();
201 boost::throw_exception(std::bad_cast());
205 #ifndef BOOST_NO_AUTO_PTR
211 pn = detail::shared_count(r);
217 #if !defined(BOOST_MSVC) || (BOOST_MSVC > 1200)
229 #ifndef BOOST_NO_AUTO_PTR
247 BOOST_ASSERT(p == 0 || p !=
px);
251 template<
class Y,
class D>
void reset(Y * p, D d)
258 BOOST_ASSERT(
px != 0);
264 BOOST_ASSERT(
px != 0);
275 #if defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x530)
277 operator bool ()
const
283 ( defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, < 0x3200) ) || \
284 ( defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304) )
318 return pn.use_count();
334 return pn.get_deleter(ti);
340 #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
350 detail::shared_count
pn;
357 return a.
get() == b.
get();
362 return a.
get() != b.
get();
365 #if __GNUC__ == 2 && __GNUC_MINOR__ <= 96
369 template<
class T>
inline bool operator!=(shared_ptr<T>
const & a, shared_ptr<T>
const & b)
371 return a.get() != b.get();
376 template<
class T,
class U>
inline bool operator<(shared_ptr<T>
const & a,
shared_ptr<U> const & b)
420 BOOST_ASSERT(dynamic_cast<T *>(r.
get()) == r.
get());
433 #if defined(__GNUC__) && (__GNUC__ < 3)
435 template<
class Y> std::ostream & operator<< (std::ostream & os, shared_ptr<Y>
const & p)
443 # if defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, <= 1200 && __SGI_STL_PORT)
445 using std::basic_ostream;
446 template<
class E,
class T,
class Y> basic_ostream<E, T> & operator<< (basic_ostream<E, T> & os, shared_ptr<Y>
const & p)
448 template<class E, class T, class Y> std::basic_ostream<E, T> &
operator<< (std::basic_ostream<E, T> & os,
shared_ptr<Y> const & p)
459 #if ( defined(__GNUC__) && BOOST_WORKAROUND(__GNUC__, < 3) ) || \
460 ( defined(__EDG_VERSION__) && BOOST_WORKAROUND(__EDG_VERSION__, <= 238) ) || \
461 ( defined(__HP_aCC) && BOOST_WORKAROUND(__HP_aCC, <= 33500) )
466 template<
class D,
class T> D *
get_deleter(shared_ptr<T>
const & p)
468 void const * q = p._internal_get_deleter(
typeid(D));
469 return const_cast<D *
>(
static_cast<D
const *
>(q));
484 # pragma warning(pop)
487 #endif // #if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES)
489 #endif // #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
491 #endif // #ifndef DEBUG_SHARED_PTR
shared_ptr(shared_ptr< Y > const &r)
shared_ptr< T > shared_dynamic_cast(shared_ptr< U > const &r)
bool _internal_less(shared_ptr< Y > const &rhs) const
bool operator!=(shared_ptr< T > const &a, shared_ptr< U > const &b)
detail::shared_ptr_traits< T >::reference reference
shared_ptr< T > this_type
shared_ptr(shared_ptr< Y > const &r, detail::dynamic_cast_tag)
void * _internal_get_deleter(std::type_info const &ti) const
shared_ptr< T > dynamic_pointer_cast(shared_ptr< U > const &r)
shared_ptr< T > const_pointer_cast(shared_ptr< U > const &r)
reference operator*() const
shared_ptr(shared_ptr< Y > const &r, detail::static_cast_tag)
shared_ptr(shared_ptr< Y > const &r, detail::const_cast_tag)
void sp_enable_shared_from_this(shared_count const &pn, boost::enable_shared_from_this< T > const *pe, Y const *px)
void swap(shared_ptr< T > &a, shared_ptr< T > &b)
shared_ptr(weak_ptr< Y > const &r)
shared_ptr< T > shared_static_cast(shared_ptr< U > const &r)
shared_ptr< T > static_pointer_cast(shared_ptr< U > const &r)
shared_ptr< T > shared_polymorphic_downcast(shared_ptr< U > const &r)
shared_ptr & operator=(std::auto_ptr< Y > &r)
shared_ptr(std::auto_ptr< Y > &r)
PBD::thing_with_backtrace< T > bt
shared_ptr & operator=(shared_ptr< Y > const &r)
void swap(shared_ptr< T > &other)
T *this_type::* unspecified_bool_type
T * get_pointer(shared_ptr< T > const &p)
shared_ptr(shared_ptr< Y > const &r, detail::polymorphic_cast_tag)
shared_ptr< T > shared_polymorphic_cast(shared_ptr< U > const &r)
D * get_deleter(shared_ptr< T > const &p)
bool operator==(shared_ptr< T > const &a, shared_ptr< U > const &b)