libcommonc++  0.7
SharedPtr< T > Class Template Reference

A threadsafe, reference-counting smart pointer. More...

#include <SharedPtr.h++>

Public Member Functions

 SharedPtr (T *object=NULL)
 Construct a new SharedPtr for the given object pointer. More...
 
 SharedPtr (const SharedPtr &other)
 Copy constructor. More...
 
 ~SharedPtr ()
 Destructor. More...
 
template<class U >
SharedPtr< U > staticCast ()
 Static cast. More...
 
template<class U >
SharedPtr< U > dynamicCast ()
 Dynamic cast. More...
 
SharedPtroperator= (const SharedPtr &other)
 Assignment operator. More...
 
SharedPtroperator= (T *object)
 Assignment operator. More...
 
T * operator-> ()
 Pointer-to-member operator. More...
 
const T * operator-> () const
 Pointer-to-member operator. More...
 
T & operator* ()
 Dereference operator. More...
 
const T & operator* () const
 Dereference operator. More...
 
T * get () const
 Get the value of the pointer. More...
 
bool operator! () const
 Test if the pointer is NULL. More...
 
 operator const void * () const
 Boolean test operator. More...
 
bool isNull () const
 Test if the pointer is NULL. More...
 
bool operator== (const SharedPtr &other) const
 Equality operator. More...
 
bool operator!= (const SharedPtr &other) const
 Inequality operator. More...
 
int getRefCount () const
 Get the reference count for this pointer. More...
 

Friends

template<class U >
class SharedPtr
 

Detailed Description

template<class T>
class ccxx::SharedPtr< T >

A threadsafe, reference-counting smart pointer.

See sections 13.6.3.1 and 25.7 of The C++ Programming Language.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ SharedPtr() [1/2]

SharedPtr ( T *  object = NULL)
inline

Construct a new SharedPtr for the given object pointer.

◆ SharedPtr() [2/2]

SharedPtr ( const SharedPtr< T > &  other)
inline

Copy constructor.

◆ ~SharedPtr()

~SharedPtr ( )
inline

Destructor.

Member Function Documentation

◆ dynamicCast()

SharedPtr<U> dynamicCast ( )
inline

Dynamic cast.

Performs a dynamic cast on the object held by this SharedPtr, and returns a new SharedPtr of the target type.

◆ get()

T* get ( ) const
inline

Get the value of the pointer.

◆ getRefCount()

int getRefCount ( ) const
inline

Get the reference count for this pointer.

◆ isNull()

bool isNull ( ) const
inline

Test if the pointer is NULL.

◆ operator const void *()

operator const void * ( ) const
inline

Boolean test operator.

(Test if the pointer is non-NULL.)

◆ operator!()

bool operator! ( ) const
inline

Test if the pointer is NULL.

◆ operator!=()

bool operator!= ( const SharedPtr< T > &  other) const
inline

Inequality operator.

Compares the object pointers.

◆ operator*() [1/2]

T& operator* ( )
inline

Dereference operator.

Exceptions
NullPointerExceptionIf this pointer is NULL.

◆ operator*() [2/2]

const T& operator* ( ) const
inline

Dereference operator.

Exceptions
NullPointerExceptionIf this pointer is NULL.

◆ operator->() [1/2]

T* operator-> ( )
inline

Pointer-to-member operator.

◆ operator->() [2/2]

const T* operator-> ( ) const
inline

Pointer-to-member operator.

◆ operator=() [1/2]

SharedPtr& operator= ( const SharedPtr< T > &  other)
inline

Assignment operator.

◆ operator=() [2/2]

SharedPtr& operator= ( T *  object)
inline

Assignment operator.

◆ operator==()

bool operator== ( const SharedPtr< T > &  other) const
inline

Equality operator.

Compares the object pointers.

◆ staticCast()

SharedPtr<U> staticCast ( )
inline

Static cast.

Performs a static cast on the object held by this SharedPtr, and returns a new SharedPtr of the target type.

Friends And Related Function Documentation

◆ SharedPtr

friend class SharedPtr
friend

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