Template for auto reference counting a pointer. More...
Public Member Functions | |
SmartPointer (T *pData) noexcept | |
Initialize a smart pointer. | |
SmartPointer () noexcept | |
Initialize a smart pointer to nullptr. | |
SmartPointer (const SmartPointer< T > &rData) noexcept | |
Copy a smart pointer. | |
~SmartPointer () | |
Release a reference to a smart pointer. | |
void | operator= (const SmartPointer< T > &rData) noexcept |
Replace the current pointer. | |
void | operator= (T *pData) noexcept |
Replace the current pointer. | |
T * | operator-> () const noexcept |
Get the current pointer. | |
T & | operator* () const noexcept |
Get the current reference. | |
operator T* () const noexcept | |
Get the current pointer. | |
T * | GetPtr () const noexcept |
Get the current pointer. | |
uint_t | operator== (const SmartPointer< T > &rData) const noexcept |
Test for equality. | |
uint_t | operator!= (const SmartPointer< T > &rData) const noexcept |
Test for inequality. | |
uint_t | operator== (const T *pData) const noexcept |
Test for equality. | |
uint_t | operator!= (const T *pData) const noexcept |
Test for inequality. | |
Private Member Functions | |
void | Replace (T *pData) noexcept |
Replace the current pointer. | |
Private Attributes | |
T * | m_pData |
Private copy of the pointer this class is tracking. | |
Template for auto reference counting a pointer.
For shared pointer classes that implement the AddRef() and Release() functions, this template will create a structure that contains a single pointer that is reference counted so shared data can be tracked.
|
inlinenoexcept |
Initialize a smart pointer.
Call AddRef() to the pointer if it's not nullptr and store the pointer inside the class for tracking.
pData | Pointer to an instance of the class T or nullptr |
|
inlinenoexcept |
|
inlinenoexcept |
Copy a smart pointer.
Call AddRef() to the pointer if it's not nullptr and store a copy of the pointer inside the class for tracking.
rData | Reference to an instance to another SmartPointer |
|
inline |
|
inlinenoexcept |
Get the current pointer.
Return an untracked copy of the pointer. The pointer can be nullptr if there is no pointer being tracked.
|
inlinenoexcept |
Get the current pointer.
Return an untracked copy of the pointer. The pointer can be nullptr if there is no pointer being tracked.
Return an untracked copy of the pointer. The pointer can be nullptr if there is no pointer being tracked.
|
inlinenoexcept |
Test for inequality.
Compare the pointers for inequality and if not equal, return TRUE
rData | Reference to an instance of another SmartPointer |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Replace the current pointer.
Test if the pointer is different to what is already contained in the class and if so, it will Release() the old data (If not nullptr) and call AddRef() to the new data (If not nullptr) and store the pointer to the new data in the class.
rData | Reference to an instance of another SmartPointer |
|
inlinenoexcept |
Replace the current pointer.
Test if the pointer is different to what is already contained in the class and if so, it will Release() the old data (If not nullptr) and call AddRef() to the new data (If not nullptr) and store the pointer to the new data in the class.
pData | Pointer to an instance of the class T or nullptr |
|
inlinenoexcept |
Test for equality.
Compare the pointers for equality and if equal, return TRUE
rData | Reference to an instance of another SmartPointer |
|
inlinenoexcept |
|
inlineprivatenoexcept |
Replace the current pointer.
This private function will test if the pointer is different to what is already contained in the class and if so, it will Release() the old data (If not nullptr) and call AddRef() to the new data (If not nullptr) and store the pointer to the new data in the class.
pData | Pointer to an instance of the class T or nullptr |
|
private |
Private copy of the pointer this class is tracking.