This reference page is linked to from the following overview topics: Smart Pointers (AutoPtr).
Standard implementation of a AutoPtr for pointer to array types.
This ArrayAutoPtr template is appropriate for any pointer to a dynamically allocated array (using new [] and delete []). To manage a single dynamically allocated object, use AutoPtr instead.
Please refer to AutoPtr's documentation for more information about AutoPtrs.
#include <autoptr.h>
Public Member Functions |
|
ArrayAutoPtr (Type *p=NULL) | |
Construct, assuming ownership of the
pointed-to object. |
|
ArrayAutoPtr (const AutoPtrRef< Type > &ref) | |
Construct from an
AutoPtrRef. |
|
template<typename OtherType > | |
operator ArrayAutoPtr< OtherType > () | |
Destructive copy-convert allowing for cast
of the pointer type. |
|
Type & | operator[] (int index) const |
Convenience array-index operator for
ArrayAutoPtrs. |
ArrayAutoPtr | ( | Type * | p = NULL |
) | [inline, explicit] |
Construct, assuming ownership of the pointed-to object.
p | Plain pointer to an array - this AutoPtr will assume ownership of that object. |
: AutoPtr<Type, ArrayPointerDestructor<Type> >(p) { };
ArrayAutoPtr | ( | const AutoPtrRef< Type > & | ref | ) | [inline] |
Construct from an AutoPtrRef.
This may be done implicitly or explicitly. The Ref object exists to avoid temporarily needing to have two AutoPtrs own the same object.
ref | helper object. |
: AutoPtr<Type, ArrayPointerDestructor<Type> >(ref.mPtr) { }
operator ArrayAutoPtr< OtherType > | ( | ) | [inline] |
Destructive copy-convert allowing for cast of the pointer type.
{ return ArrayAutoPtr<OtherType>(this->Release()); }
Type& operator[] | ( | int | index | ) | const [inline] |
Convenience array-index operator for ArrayAutoPtrs.
Using this operator is the same as calling Get()[index]. Note that this operator does not check if the index is out of bounds. This is not a bounds checking smart pointer, it's just a handy guard object for dealing with memory ownership.
index | The index within the array |
{ return Get()[index]; }