Miosix  2.0alpha1
miosix::intrusive_ref_ptr< T > Class Template Reference

#include <intrusive.h>

Public Types

typedef T element_type
 As shared_ptr, expose the managed type.
 

Public Member Functions

 intrusive_ref_ptr ()
 
 intrusive_ref_ptr (T *o)
 
template<typename U >
 intrusive_ref_ptr (U *o)
 
 intrusive_ref_ptr (const intrusive_ref_ptr &rhs)
 
template<typename U >
 intrusive_ref_ptr (const intrusive_ref_ptr< U > &rhs)
 
intrusive_ref_ptroperator= (const intrusive_ref_ptr &rhs)
 
template<typename U >
intrusive_ref_ptroperator= (const intrusive_ref_ptr< U > &rhs)
 
intrusive_ref_ptroperator= (T *o)
 
T * get () const
 
T & operator* () const
 
T * operator-> () const
 
 operator SafeBool () const
 
void swap (intrusive_ref_ptr &rhs)
 
void reset ()
 
int use_count () const
 
 ~intrusive_ref_ptr ()
 

Detailed Description

template<typename T>
class miosix::intrusive_ref_ptr< T >

Reference counted pointer to intrusively reference counted objects. This class is made in a way to resemble the shared_ptr class, as specified in chapter 20.7.2.2 of the C++11 standard.

Thread safety of this class is the same as shared_ptr. The reference count is updated using atomic operations, but this does not make all kind of concurrent access to the same intrusive_ref_ptr safe. A good reference that explains why is www.drdobbs.com/cpp/a-base-class-for-intrusively-reference-c/229218807?pgno=3

Parameters
Ttype to which the object points

Constructor & Destructor Documentation

template<typename T>
miosix::intrusive_ref_ptr< T >::intrusive_ref_ptr ( )
inline

Default constructor

template<typename T>
miosix::intrusive_ref_ptr< T >::intrusive_ref_ptr ( T *  o)
inlineexplicit

Constructor, with raw pointer

Parameters
objectobject to manage
template<typename T>
template<typename U >
miosix::intrusive_ref_ptr< T >::intrusive_ref_ptr ( U *  o)
inlineexplicit

Generalized constructor, with raw pointer

Parameters
objectobject to manage
template<typename T>
miosix::intrusive_ref_ptr< T >::intrusive_ref_ptr ( const intrusive_ref_ptr< T > &  rhs)
inline

Copy constructor, with same type of managed pointer

Parameters
rhsobject to manage
template<typename T>
template<typename U >
miosix::intrusive_ref_ptr< T >::intrusive_ref_ptr ( const intrusive_ref_ptr< U > &  rhs)
inline

Generalized copy constructor, to support upcast among refcounted pointers

Parameters
rhsobject to manage
template<typename T>
miosix::intrusive_ref_ptr< T >::~intrusive_ref_ptr ( )
inline

Destructor

Member Function Documentation

template<typename T>
T* miosix::intrusive_ref_ptr< T >::get ( ) const
inline
Returns
a pointer to the managed object
template<typename T>
miosix::intrusive_ref_ptr< T >::operator SafeBool ( ) const
inline
Returns
true if the object contains a callback
template<typename T>
T& miosix::intrusive_ref_ptr< T >::operator* ( ) const
inline
Returns
a reference to the managed object
template<typename T>
T* miosix::intrusive_ref_ptr< T >::operator-> ( ) const
inline

Allows this class to behave like the managed type

Returns
a pointer to the managed object
template<typename T >
intrusive_ref_ptr< T > & miosix::intrusive_ref_ptr< T >::operator= ( const intrusive_ref_ptr< T > &  rhs)

Operator=, with same type of managed pointer

Parameters
rhsobject to manage
Returns
a reference to *this
template<typename T>
template<typename U >
intrusive_ref_ptr& miosix::intrusive_ref_ptr< T >::operator= ( const intrusive_ref_ptr< U > &  rhs)

Generalized perator=, to support upcast among refcounted pointers

Parameters
rhsobject to manage
Returns
a reference to *this
template<typename T>
intrusive_ref_ptr< T > & miosix::intrusive_ref_ptr< T >::operator= ( T *  o)

Operator=, with raw pointer

Parameters
rhsobject to manage
Returns
a reference to *this
template<typename T>
void miosix::intrusive_ref_ptr< T >::reset ( )
inline

After a call to this member function, this intrusive_ref_ptr no longer points to the managed object. The managed object is deleted if this was the only pointer at it

template<typename T>
void miosix::intrusive_ref_ptr< T >::swap ( intrusive_ref_ptr< T > &  rhs)
inline

Swap the managed object with another intrusive_ref_ptr

Parameters
rhsthe other smart pointer
template<typename T>
int miosix::intrusive_ref_ptr< T >::use_count ( ) const
inline
Returns
the number of intrusive_ref_ptr that point to the managed object. If return 0, than this points to nullptr

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