This is Unofficial EPICS BASE Doxygen Site
boost::detail::shared_count Class Reference

#include "shared_count.hpp"

Public Member Functions

 shared_count ()
 
template<class Y >
 shared_count (Y *p)
 
template<class P , class D >
 shared_count (P p, D d)
 
template<class P , class D >
 shared_count (P p, sp_inplace_tag< D >)
 
template<class P , class D , class A >
 shared_count (P p, D d, A a)
 
template<class P , class D , class A >
 shared_count (P p, sp_inplace_tag< D >, A a)
 
template<class Y >
 shared_count (std::auto_ptr< Y > &r)
 
template<class Y , class D >
 shared_count (std::unique_ptr< Y, D > &r)
 
 ~shared_count ()
 
 shared_count (shared_count const &r)
 
 shared_count (shared_count &&r)
 
 shared_count (weak_count const &r)
 
 shared_count (weak_count const &r, sp_nothrow_tag)
 
shared_countoperator= (shared_count const &r)
 
void swap (shared_count &r)
 
long use_count () const
 
bool unique () const
 
bool empty () const
 
void * get_deleter (sp_typeinfo const &ti) const
 
void * get_untyped_deleter () const
 

Friends

class weak_count
 
bool operator== (shared_count const &a, shared_count const &b)
 
bool operator< (shared_count const &a, shared_count const &b)
 

Detailed Description

Definition at line 100 of file shared_count.hpp.

Constructor & Destructor Documentation

boost::detail::shared_count::shared_count ( )
inline

Definition at line 114 of file shared_count.hpp.

114  : pi_(0) // nothrow
115 #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
116  , id_(shared_count_id)
117 #endif
118  {
119  }
template<class Y >
boost::detail::shared_count::shared_count ( Y *  p)
inlineexplicit

Definition at line 121 of file shared_count.hpp.

121  : pi_( 0 )
122 #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
123  , id_(shared_count_id)
124 #endif
125  {
126 #ifndef BOOST_NO_EXCEPTIONS
127 
128  try
129  {
130  pi_ = new sp_counted_impl_p<Y>( p );
131  }
132  catch(...)
133  {
135  throw;
136  }
137 
138 #else
139 
140  pi_ = new sp_counted_impl_p<Y>( p );
141 
142  if( pi_ == 0 )
143  {
145  boost::throw_exception( std::bad_alloc() );
146  }
147 
148 #endif
149  }
void checked_delete(T *x)
BOOST_ATTRIBUTE_NORETURN void throw_exception(E const &e)
template<class P , class D >
boost::detail::shared_count::shared_count ( p,
d 
)
inline

Definition at line 154 of file shared_count.hpp.

154  : pi_(0)
155 #endif
156 #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
157  , id_(shared_count_id)
158 #endif
159  {
160 #if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1200 )
161  typedef Y* P;
162 #endif
163 #ifndef BOOST_NO_EXCEPTIONS
164 
165  try
166  {
167  pi_ = new sp_counted_impl_pd<P, D>(p, d);
168  }
169  catch(...)
170  {
171  d(p); // delete p
172  throw;
173  }
174 
175 #else
176 
177  pi_ = new sp_counted_impl_pd<P, D>(p, d);
178 
179  if(pi_ == 0)
180  {
181  d(p); // delete p
182  boost::throw_exception(std::bad_alloc());
183  }
184 
185 #endif
186  }
BOOST_ATTRIBUTE_NORETURN void throw_exception(E const &e)
template<class P , class D >
boost::detail::shared_count::shared_count ( p,
sp_inplace_tag< D >   
)
inline

Definition at line 190 of file shared_count.hpp.

190  : pi_( 0 )
191 #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
192  , id_(shared_count_id)
193 #endif
194  {
195 #ifndef BOOST_NO_EXCEPTIONS
196 
197  try
198  {
199  pi_ = new sp_counted_impl_pd< P, D >( p );
200  }
201  catch( ... )
202  {
203  D()( p ); // delete p
204  throw;
205  }
206 
207 #else
208 
209  pi_ = new sp_counted_impl_pd< P, D >( p );
210 
211  if( pi_ == 0 )
212  {
213  D()( p ); // delete p
214  boost::throw_exception( std::bad_alloc() );
215  }
216 
217 #endif // #ifndef BOOST_NO_EXCEPTIONS
218  }
BOOST_ATTRIBUTE_NORETURN void throw_exception(E const &e)
template<class P , class D , class A >
boost::detail::shared_count::shared_count ( p,
d,
a 
)
inline

Definition at line 222 of file shared_count.hpp.

222  : pi_( 0 )
223 #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
224  , id_(shared_count_id)
225 #endif
226  {
227  typedef sp_counted_impl_pda<P, D, A> impl_type;
228  typedef typename A::template rebind< impl_type >::other A2;
229 
230  A2 a2( a );
231 
232 #ifndef BOOST_NO_EXCEPTIONS
233 
234  try
235  {
236  pi_ = a2.allocate( 1, static_cast< impl_type* >( 0 ) );
237  new( static_cast< void* >( pi_ ) ) impl_type( p, d, a );
238  }
239  catch(...)
240  {
241  d( p );
242 
243  if( pi_ != 0 )
244  {
245  a2.deallocate( static_cast< impl_type* >( pi_ ), 1 );
246  }
247 
248  throw;
249  }
250 
251 #else
252 
253  pi_ = a2.allocate( 1, static_cast< impl_type* >( 0 ) );
254 
255  if( pi_ != 0 )
256  {
257  new( static_cast< void* >( pi_ ) ) impl_type( p, d, a );
258  }
259  else
260  {
261  d( p );
262  boost::throw_exception( std::bad_alloc() );
263  }
264 
265 #endif
266  }
BOOST_ATTRIBUTE_NORETURN void throw_exception(E const &e)
template<class P , class D , class A >
boost::detail::shared_count::shared_count ( p,
sp_inplace_tag< D >  ,
a 
)
inline

Definition at line 270 of file shared_count.hpp.

270  : pi_( 0 )
271 #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
272  , id_(shared_count_id)
273 #endif
274  {
275  typedef sp_counted_impl_pda< P, D, A > impl_type;
276  typedef typename A::template rebind< impl_type >::other A2;
277 
278  A2 a2( a );
279 
280 #ifndef BOOST_NO_EXCEPTIONS
281 
282  try
283  {
284  pi_ = a2.allocate( 1, static_cast< impl_type* >( 0 ) );
285  new( static_cast< void* >( pi_ ) ) impl_type( p, a );
286  }
287  catch(...)
288  {
289  D()( p );
290 
291  if( pi_ != 0 )
292  {
293  a2.deallocate( static_cast< impl_type* >( pi_ ), 1 );
294  }
295 
296  throw;
297  }
298 
299 #else
300 
301  pi_ = a2.allocate( 1, static_cast< impl_type* >( 0 ) );
302 
303  if( pi_ != 0 )
304  {
305  new( static_cast< void* >( pi_ ) ) impl_type( p, a );
306  }
307  else
308  {
309  D()( p );
310  boost::throw_exception( std::bad_alloc() );
311  }
312 
313 #endif // #ifndef BOOST_NO_EXCEPTIONS
314  }
BOOST_ATTRIBUTE_NORETURN void throw_exception(E const &e)
template<class Y >
boost::detail::shared_count::shared_count ( std::auto_ptr< Y > &  r)
inlineexplicit

Definition at line 323 of file shared_count.hpp.

323  : pi_( new sp_counted_impl_p<Y>( r.get() ) )
324 #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
325  , id_(shared_count_id)
326 #endif
327  {
328 #ifdef BOOST_NO_EXCEPTIONS
329 
330  if( pi_ == 0 )
331  {
332  boost::throw_exception(std::bad_alloc());
333  }
334 
335 #endif
336 
337  r.release();
338  }
BOOST_ATTRIBUTE_NORETURN void throw_exception(E const &e)
template<class Y , class D >
boost::detail::shared_count::shared_count ( std::unique_ptr< Y, D > &  r)
inlineexplicit

Definition at line 345 of file shared_count.hpp.

345  : pi_( 0 )
346 #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
347  , id_(shared_count_id)
348 #endif
349  {
350  typedef typename sp_convert_reference<D>::type D2;
351 
352  D2 d2( r.get_deleter() );
353  pi_ = new sp_counted_impl_pd< typename std::unique_ptr<Y, D>::pointer, D2 >( r.get(), d2 );
354 
355 #ifdef BOOST_NO_EXCEPTIONS
356 
357  if( pi_ == 0 )
358  {
359  boost::throw_exception( std::bad_alloc() );
360  }
361 
362 #endif
363 
364  r.release();
365  }
BOOST_ATTRIBUTE_NORETURN void throw_exception(E const &e)
boost::detail::shared_count::~shared_count ( )
inline

Definition at line 369 of file shared_count.hpp.

370  {
371  if( pi_ != 0 ) pi_->release();
372 #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
373  id_ = 0;
374 #endif
375  }
boost::detail::shared_count::shared_count ( shared_count const &  r)
inline

Definition at line 377 of file shared_count.hpp.

377  : pi_(r.pi_) // nothrow
378 #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
379  , id_(shared_count_id)
380 #endif
381  {
382  if( pi_ != 0 ) pi_->add_ref_copy();
383  }
boost::detail::shared_count::shared_count ( shared_count &&  r)
inline

Definition at line 387 of file shared_count.hpp.

387  : pi_(r.pi_) // nothrow
388 #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
389  , id_(shared_count_id)
390 #endif
391  {
392  r.pi_ = 0;
393  }
boost::detail::shared_count::shared_count ( weak_count const &  r)
inlineexplicit

Definition at line 573 of file shared_count.hpp.

573  : pi_( r.pi_ )
574 #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
575  , id_(shared_count_id)
576 #endif
577 {
578  if( pi_ == 0 || !pi_->add_ref_lock() )
579  {
581  }
582 }
BOOST_ATTRIBUTE_NORETURN void throw_exception(E const &e)
boost::detail::shared_count::shared_count ( weak_count const &  r,
sp_nothrow_tag   
)
inline

Definition at line 584 of file shared_count.hpp.

584  : pi_( r.pi_ )
585 #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
586  , id_(shared_count_id)
587 #endif
588 {
589  if( pi_ != 0 && !pi_->add_ref_lock() )
590  {
591  pi_ = 0;
592  }
593 }

Member Function Documentation

bool boost::detail::shared_count::empty ( ) const
inline

Definition at line 431 of file shared_count.hpp.

432  {
433  return pi_ == 0;
434  }
void* boost::detail::shared_count::get_deleter ( sp_typeinfo const &  ti) const
inline

Definition at line 446 of file shared_count.hpp.

447  {
448  return pi_? pi_->get_deleter( ti ): 0;
449  }
virtual void * get_deleter(sp_typeinfo const &ti)=0
void* boost::detail::shared_count::get_untyped_deleter ( ) const
inline

Definition at line 451 of file shared_count.hpp.

452  {
453  return pi_? pi_->get_untyped_deleter(): 0;
454  }
virtual void * get_untyped_deleter()=0
shared_count& boost::detail::shared_count::operator= ( shared_count const &  r)
inline

Definition at line 400 of file shared_count.hpp.

401  {
402  sp_counted_base * tmp = r.pi_;
403 
404  if( tmp != pi_ )
405  {
406  if( tmp != 0 ) tmp->add_ref_copy();
407  if( pi_ != 0 ) pi_->release();
408  pi_ = tmp;
409  }
410 
411  return *this;
412  }
void boost::detail::shared_count::swap ( shared_count r)
inline

Definition at line 414 of file shared_count.hpp.

415  {
416  sp_counted_base * tmp = r.pi_;
417  r.pi_ = pi_;
418  pi_ = tmp;
419  }
bool boost::detail::shared_count::unique ( ) const
inline

Definition at line 426 of file shared_count.hpp.

427  {
428  return use_count() == 1;
429  }
long boost::detail::shared_count::use_count ( ) const
inline

Definition at line 421 of file shared_count.hpp.

422  {
423  return pi_ != 0? pi_->use_count(): 0;
424  }

Friends And Related Function Documentation

bool operator< ( shared_count const &  a,
shared_count const &  b 
)
friend

Definition at line 441 of file shared_count.hpp.

442  {
443  return std::less<sp_counted_base *>()( a.pi_, b.pi_ );
444  }
bool operator== ( shared_count const &  a,
shared_count const &  b 
)
friend

Definition at line 436 of file shared_count.hpp.

437  {
438  return a.pi_ == b.pi_;
439  }
friend class weak_count
friend

Definition at line 110 of file shared_count.hpp.


The documentation for this class was generated from the following file: