1 #ifndef BOOSTER_SMART_PTR_DETAIL_SHARED_COUNT_HPP_INCLUDED 2 #define BOOSTER_SMART_PTR_DETAIL_SHARED_COUNT_HPP_INCLUDED 15 # pragma warn -8027 // Functions containing try are not expanded inline 18 #include <booster/config.h> 19 #include <booster/checked_delete.h> 20 #include <booster/bad_weak_ptr.h> 21 #include <booster/smart_ptr/sp_counted_base.h> 22 #include <booster/smart_ptr/sp_counted_impl.h> 23 #include <booster/auto_ptr_inc.h> 51 template<
class Y>
explicit shared_count( Y * p ): pi_( 0 )
59 booster::checked_delete( p );
64 template<
class P,
class D>
shared_count( P p, D d ): pi_(0)
77 template<
class P,
class D,
class A>
shared_count( P p, D d, A a ): pi_( 0 )
80 typedef typename A::template rebind< impl_type >::other A2;
86 pi_ = a2.allocate( 1, static_cast< impl_type* >( 0 ) );
87 new(
static_cast< void*
>( pi_ ) ) impl_type( p, d, a );
95 a2.deallocate( static_cast< impl_type* >( pi_ ), 1 );
115 if( pi_ != 0 ) pi_->release();
120 if( pi_ != 0 ) pi_->add_ref_copy();
132 if( tmp != 0 ) tmp->add_ref_copy();
133 if( pi_ != 0 ) pi_->release();
147 long use_count()
const 149 return pi_ != 0? pi_->use_count(): 0;
154 return use_count() == 1;
164 return a.pi_ == b.pi_;
169 return std::less<sp_counted_base *>()( a.pi_, b.pi_ );
172 void * get_deleter( sp_typeinfo
const & ti )
const 174 return pi_? pi_->get_deleter( ti ): 0;
195 if(pi_ != 0) pi_->weak_add_ref();
200 if(pi_ != 0) pi_->weak_add_ref();
206 if(pi_ != 0) pi_->weak_release();
215 if(tmp != 0) tmp->weak_add_ref();
216 if(pi_ != 0) pi_->weak_release();
229 if(tmp != 0) tmp->weak_add_ref();
230 if(pi_ != 0) pi_->weak_release();
244 long use_count()
const 246 return pi_ != 0? pi_->use_count(): 0;
256 return a.pi_ == b.pi_;
261 return std::less<sp_counted_base *>()(a.pi_, b.pi_);
265 inline shared_count::shared_count(
weak_count const & r ): pi_( r.pi_ )
267 if( pi_ == 0 || !pi_->add_ref_lock() )
275 if( pi_ != 0 && !pi_->add_ref_lock() )
286 # pragma warn .8027 // Functions containing try are not expanded inline 289 #endif // #ifndef BOOST_SMART_PTR_DETAIL_SHARED_COUNT_HPP_INCLUDED Definition: shared_count.h:37
Definition: sp_counted_base.h:39
Definition: sp_counted_impl.h:77
Definition: shared_count.h:179
Definition: sp_counted_impl.h:32
Definition: sp_counted_impl.h:119
Definition: shared_count.h:33
Booster library namespace. The library that implements Boost Like API in ABI backward compatible way...
Definition: application.h:23
Definition: bad_weak_ptr.h:36