#include <gxAutoPtr.h>
Public Member Functions | |
gxAutoPtr (T *ptr=NULL) | |
Constructor allows an optional raw pointer to be attached to the auto pointer. | |
virtual | ~gxAutoPtr () |
Destructor ensures that the attached object (if any) is deleted when the auto pointer goes out of scope. | |
T ** | operator & () |
Override of the "&" operator returns the address of the raw pointer. | |
T * | operator-> () |
Override of the "->" operator allows the auto pointer to be dereferenced just like a raw pointer. | |
bool | operator== (gxAutoPtr< T > &rhs) |
Override of the "==" operator. | |
bool | operator== (T *rhs) |
Override of the "==" operator which compares the wrapped raw pointer with a supplied raw pointer. | |
gxAutoPtr & | operator= (T *rhs) |
The assignment operator only works with raw pointers. | |
operator T * () | |
The assignment operator only works with raw pointers. | |
void | clear () |
void | assign (T *rhs) |
The assignment method only works with raw pointers. | |
T * | detach () |
Retrieve the current raw pointer and clear the auto ptr. | |
Public Attributes | |
T * | m_ptr |
Serves the same purpose as the std::auto_ptr template class, but is easier to use within gxLib ( std::auto_ptr only allows the raw pointer to be assigned to the auto_ptr in the constructor) In gxLib it is convenient to pass the address of the auto_ptr to factory methods which return a pointer to the new object via an output param, as in the example below:
extern objectFactory( object ** newObject );
gxAutoPtr<object> myObject; objectFactory::create( &myObject );
|
Constructor allows an optional raw pointer to be attached to the auto pointer.
|
|
Destructor ensures that the attached object (if any) is deleted when the auto pointer goes out of scope.
|
|
The assignment method only works with raw pointers. When you assign a raw pointer to the auto ptr, it deletes any existing object and replaces with the supplied pointer. |
|
|
|
Retrieve the current raw pointer and clear the auto ptr. The object is not deleted. |
|
Override of the "&" operator returns the address of the raw pointer.
|
|
The assignment operator only works with raw pointers. When you assign a raw pointer to the auto ptr, it deletes any existing object and replaces with the supplied pointer. |
|
Override of the "->" operator allows the auto pointer to be dereferenced just like a raw pointer.
|
|
The assignment operator only works with raw pointers. When you assign a raw pointer to the auto ptr, it deletes any existing object and replaces with the supplied pointer. |
|
Override of the "==" operator which compares the wrapped raw pointer with a supplied raw pointer.
|
|
Override of the "==" operator. Two auto ptrs are equal if they contain the same raw pointer. |
|
|