FbxAutoPtr< Type, Policy > Class Template Reference

FbxAutoPtr< Type, Policy > Class Template Reference

#include <fbxalloc.h>

Class Description

template<class Type, class Policy = FbxDeletionPolicyDefault<Type>>
class FbxAutoPtr< Type, Policy >

FbxAutoPtr mimics the auto_ptr class template implementation available in the C++ Standard Library.

The auto_ptr template class describes an object that stores a pointer to a single allocated object of type Type* that ensures that the object to which it points gets destroyed automatically when control leaves a scope.

+ Examples:

Definition at line 188 of file fbxalloc.h.

Public Member Functions

 FbxAutoPtr (Type *pPtr=0)
 Construct from a pointer. More...
 
 ~FbxAutoPtr ()
 Destructor. More...
 
Type * Get () const
 Retrieve the pointer it holds. More...
 
Type * operator-> () const
 Member access operator. More...
 
 operator Type * () const
 Convert to a Type pointer. More...
 
Type & operator* () const
 Dereference operator. More...
 
bool operator! () const
 Logical not operator. More...
 
 operator bool () const
 Convert to boolean value. More...
 
void Reset (Type *pPtr=0)
 Reset the scoped pointer by swapping with another pointer. More...
 
void Swap (FbxAutoPtr &pOther)
 Swap with another pointer. More...
 
Type * Release ()
 Release the pointer, so that it won't perform deletion in its destruction. More...
 

Constructor & Destructor Documentation

FbxAutoPtr ( Type *  pPtr = 0)
inlineexplicit

Construct from a pointer.

Definition at line 192 of file fbxalloc.h.

192 : mPtr(pPtr){}
~FbxAutoPtr ( )
inline

Destructor.

Definition at line 195 of file fbxalloc.h.

195 { Policy::DeleteIt(&mPtr); }

Member Function Documentation

Type* Get ( ) const
inline

Retrieve the pointer it holds.

Definition at line 198 of file fbxalloc.h.

198 { return mPtr; }
Type* operator-> ( ) const
inline

Member access operator.

Definition at line 201 of file fbxalloc.h.

201 { return mPtr; }
operator Type * ( ) const
inline

Convert to a Type pointer.

Definition at line 204 of file fbxalloc.h.

204 { return mPtr; }
Type& operator* ( ) const
inline

Dereference operator.

Definition at line 207 of file fbxalloc.h.

207 { return *mPtr; }
bool operator! ( ) const
inline

Logical not operator.

Definition at line 210 of file fbxalloc.h.

210 { return mPtr == 0; }
operator bool ( ) const
inline

Convert to boolean value.

Definition at line 213 of file fbxalloc.h.

213 { return mPtr != 0; }
void Reset ( Type *  pPtr = 0)
inline

Reset the scoped pointer by swapping with another pointer.

Definition at line 216 of file fbxalloc.h.

217  {
218  FBX_ASSERT(pPtr == 0 || pPtr != mPtr); //Catch self-reset errors
219  FbxAutoPtr<Type, Policy>(pPtr).Swap(*this);
220  }
FbxAutoPtr mimics the auto_ptr class template implementation available in the C++ Standard Library...
Definition: fbxalloc.h:188
void Swap(FbxAutoPtr &pOther)
Swap with another pointer.
Definition: fbxalloc.h:223
void Swap ( FbxAutoPtr< Type, Policy > &  pOther)
inline

Swap with another pointer.

Definition at line 223 of file fbxalloc.h.

224  {
225  Type* TmpPtr = pOther.mPtr;
226  pOther.mPtr = mPtr;
227  mPtr = TmpPtr;
228  }
Type* Release ( )
inline

Release the pointer, so that it won't perform deletion in its destruction.

Definition at line 231 of file fbxalloc.h.

232  {
233  Type* TmpPtr = mPtr;
234  mPtr = NULL;
235  return TmpPtr;
236  }
#define NULL
Definition: fbxarch.h:207

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