proxygen
counted_ptr< T, Atom > Class Template Reference

#include <AtomicSharedPtrCounted.h>

Inheritance diagram for counted_ptr< T, Atom >:
counted_ptr_base< Atom >

Public Member Functions

 counted_ptr ()
 
 counted_ptr (counted_shared_tag, T *p)
 
 counted_ptr (const counted_ptr &o)
 
counted_ptroperator= (const counted_ptr &o)
 
 counted_ptr (T *p)
 
 ~counted_ptr ()
 
std::add_lvalue_reference< T >::type operator* () const
 
Tget () const
 
Toperator-> () const
 
 operator bool () const
 
bool operator== (const counted_ptr< T, Atom > &p) const
 

Public Attributes

Tp_
 

Additional Inherited Members

- Static Protected Member Functions inherited from counted_ptr_base< Atom >
static intrusive_shared_count< Atom > * getRef (void *pt)
 

Detailed Description

template<typename T, template< typename > class Atom = std::atomic>
class counted_ptr< T, Atom >

Definition at line 47 of file AtomicSharedPtrCounted.h.

Constructor & Destructor Documentation

template<typename T, template< typename > class Atom = std::atomic>
counted_ptr< T, Atom >::counted_ptr ( )
inline

Definition at line 50 of file AtomicSharedPtrCounted.h.

50 : p_(nullptr) {}
template<typename T, template< typename > class Atom = std::atomic>
counted_ptr< T, Atom >::counted_ptr ( counted_shared_tag  ,
T p 
)
inline

Definition at line 51 of file AtomicSharedPtrCounted.h.

References counted_ptr_base< Atom >::getRef().

51  : p_(p) {
52  if (p_) {
54  }
55  }
static intrusive_shared_count< Atom > * getRef(void *pt)
template<typename T, template< typename > class Atom = std::atomic>
counted_ptr< T, Atom >::counted_ptr ( const counted_ptr< T, Atom > &  o)
inline

Definition at line 57 of file AtomicSharedPtrCounted.h.

References counted_ptr_base< Atom >::getRef().

57  : p_(o.p_) {
58  if (p_) {
60  }
61  }
static intrusive_shared_count< Atom > * getRef(void *pt)
template<typename T, template< typename > class Atom = std::atomic>
counted_ptr< T, Atom >::counted_ptr ( T p)
inlineexplicit

Definition at line 73 of file AtomicSharedPtrCounted.h.

73  : p_(p) {
74  CHECK(!p);
75  }
template<typename T, template< typename > class Atom = std::atomic>
counted_ptr< T, Atom >::~counted_ptr ( )
inline

Definition at line 76 of file AtomicSharedPtrCounted.h.

References bm::free().

76  {
77  if (p_ && counted_ptr_base<Atom>::getRef(p_)->release_ref() == 1) {
78  p_->~T();
80  }
81  }
void free()

Member Function Documentation

template<typename T, template< typename > class Atom = std::atomic>
T* counted_ptr< T, Atom >::get ( ) const
inline

Definition at line 86 of file AtomicSharedPtrCounted.h.

Referenced by counted_ptr< T, Atom >::operator==().

86  {
87  return p_;
88  }
template<typename T, template< typename > class Atom = std::atomic>
counted_ptr< T, Atom >::operator bool ( ) const
inlineexplicit

Definition at line 92 of file AtomicSharedPtrCounted.h.

92  {
93  return p_ == nullptr ? false : true;
94  }
template<typename T, template< typename > class Atom = std::atomic>
std::add_lvalue_reference<T>::type counted_ptr< T, Atom >::operator* ( ) const
inline

Definition at line 82 of file AtomicSharedPtrCounted.h.

82  {
83  return *p_;
84  }
template<typename T, template< typename > class Atom = std::atomic>
T* counted_ptr< T, Atom >::operator-> ( ) const
inline

Definition at line 89 of file AtomicSharedPtrCounted.h.

89  {
90  return p_;
91  }
template<typename T, template< typename > class Atom = std::atomic>
counted_ptr& counted_ptr< T, Atom >::operator= ( const counted_ptr< T, Atom > &  o)
inline

Definition at line 62 of file AtomicSharedPtrCounted.h.

References bm::free(), counted_ptr_base< Atom >::getRef(), and counted_ptr< T, Atom >::p_.

62  {
63  if (p_ && counted_ptr_base<Atom>::getRef(p_)->release_ref() == 1) {
64  p_->~T();
66  }
67  p_ = o.p_;
68  if (p_) {
70  }
71  return *this;
72  }
static intrusive_shared_count< Atom > * getRef(void *pt)
void free()
template<typename T, template< typename > class Atom = std::atomic>
bool counted_ptr< T, Atom >::operator== ( const counted_ptr< T, Atom > &  p) const
inline

Definition at line 95 of file AtomicSharedPtrCounted.h.

References testing::Args(), Atom, counted_ptr< T, Atom >::get(), and T.

95  {
96  return get() == p.get();
97  }

Member Data Documentation

template<typename T, template< typename > class Atom = std::atomic>
T* counted_ptr< T, Atom >::p_

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