Core Library
|
A reference counted smart pointer. More...
#include <SharedPtr.hpp>
Public Member Functions | |
SharedPtr () | |
Default constructor. | |
SharedPtr (T *pPointer) | |
Construction from a raw pointer. | |
SharedPtr (const SharedPtr< T > &oPointer) | |
Copy constructor. | |
template<typename U > | |
SharedPtr (const SharedPtr< U > &oPointer) | |
Copy constructor for sub-types of T. | |
~SharedPtr () | |
Destructor. | |
SharedPtr & | operator= (const SharedPtr &oPointer) |
Assignment operator. | |
template<typename U > | |
SharedPtr & | operator= (const SharedPtr< U > &oPointer) |
Assignment operator for sub-types of T. | |
void | reset (T *pPointer=nullptr) |
Change pointer ownership. | |
Private Member Functions | |
SharedPtr (T *pPointer, long *pRefCnt) | |
Private constructor for use by cast functions. | |
Private Attributes | |
long * | m_pRefCnt |
The pointer reference count. | |
Friends | |
class | SharedPtr |
Allow member access for SharedPtrs of sub-types. | |
template<typename P , typename U > | |
SharedPtr< P > | static_ptr_cast (const SharedPtr< U > &oPointer) |
Allow member access for the static_cast like function. | |
template<typename P , typename U > | |
SharedPtr< P > | dynamic_ptr_cast (const SharedPtr< U > &oPointer) |
Allow member access for the dynamic_cast like function. |
A reference counted smart pointer.
Core::SharedPtr< T >::SharedPtr | ( | ) |
Default constructor.
Core::SharedPtr< T >::SharedPtr | ( | T * | pPointer | ) | [inline, explicit] |
Construction from a raw pointer.
Takes ownership of a new pointer.
Core::SharedPtr< T >::SharedPtr | ( | const SharedPtr< T > & | oPointer | ) | [inline] |
Copy constructor.
Takes shared ownership of another pointer.
Core::SharedPtr< T >::SharedPtr | ( | const SharedPtr< U > & | oPointer | ) | [inline] |
Copy constructor for sub-types of T.
Takes shared ownership of another pointer that must be a sub-type of T..
Core::SharedPtr< T >::~SharedPtr | ( | ) | [inline] |
Destructor.
Frees the pointer if the last reference.
Core::SharedPtr< T >::SharedPtr | ( | T * | pPointer, |
long * | pRefCnt | ||
) | [inline, private] |
Private constructor for use by cast functions.
SharedPtr< T > & Core::SharedPtr< T >::operator= | ( | const SharedPtr< T > & | oPointer | ) | [inline] |
Assignment operator.
Frees the current pointer if the last reference and takes shared ownership of another pointer.
SharedPtr< T > & Core::SharedPtr< T >::operator= | ( | const SharedPtr< U > & | oPointer | ) | [inline] |
Assignment operator for sub-types of T.
Frees the current pointer if the last reference and takes shared ownership of another pointer that must be a sub-type of T.
void Core::SharedPtr< T >::reset | ( | T * | pPointer = nullptr | ) | [inline] |
Change pointer ownership.
Frees the current pointer if the last reference and takes shared ownership of another pointer, if provided.
Core::SharedPtr< T >::SharedPtr [friend] |
Allow member access for SharedPtrs of sub-types.
Default constructor.
Sets pointer and reference count to NULL.
SharedPtr<P> static_ptr_cast | ( | const SharedPtr< U > & | oPointer | ) | [friend] |
Allow member access for the static_cast like function.
SharedPtr<P> dynamic_ptr_cast | ( | const SharedPtr< U > & | oPointer | ) | [friend] |
Allow member access for the dynamic_cast like function.
long* Core::SharedPtr< T >::m_pRefCnt [private] |
The pointer reference count.