Template definition for classes that help guarding against dangling pointers. More...
#include <fcleanup.h>
Public Member Functions | |
FPtrNuller (T *&_toNull) | |
Constructor. _toNull is a reference to the pointer that is to be reset to NULL when this FPtrNuller object's destructor is executed. | |
~FPtrNuller () | |
Destructor. Calls delete[] on the at construction time passed pointer. | |
Data Fields | |
T *& | toNull |
Remembers the pointer that is to be set to NULL during destruction. |
Template definition for classes that help guarding against dangling pointers.
A stack allocated object of this type autonomically resets an at construction time passed pointer to null when it reaches the end of its scope.
Intended usage:
int* pointerToInt = 0; { int i = 1; pointerToInt = &i; Steinberg::FPtrNuller<int> ptrNuller (pointerToInt); // Do something with pointerToInt. } // No dangling pointer here, pointerToInt is reset to 0 by destructor of ptrNuller.
FPtrNuller | ( | T *& | _toNull | ) | [inline] |
Constructor. _toNull is a reference to the pointer that is to be reset to NULL when this FPtrNuller object's destructor is executed.
~FPtrNuller | ( | ) | [inline] |
Destructor. Calls delete[] on the at construction time passed pointer.
T*& toNull |
Remembers the pointer that is to be set to NULL during destruction.