Base Module VST 3.7
SDK for developing VST plug-in
FPtrNuller< T > Struct Template Reference

Template definition for classes that help guarding against dangling pointers. More...

#include <fcleanup.h>

Public Member Functions

 FPtrNuller (T *&_toNull)
 Constructor. More...
 
 ~FPtrNuller ()
 Destructor. Calls delete[] on the at construction time passed pointer. More...
 

Public Attributes

T *& toNull
 Remembers the pointer that is to be set to NULL during destruction. More...
 

Detailed Description

template<class T>
struct Steinberg::FPtrNuller< T >

Template definition for classes that help guarding against dangling pointers.

A stack allocated object of this type automatically 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.
Template definition for classes that help guarding against dangling pointers.
Definition: fcleanup.h:125

Constructor & Destructor Documentation

◆ FPtrNuller()

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()

~FPtrNuller ( )
inline

Destructor. Calls delete[] on the at construction time passed pointer.

Member Data Documentation

◆ toNull

T*& toNull

Remembers the pointer that is to be set to NULL during destruction.

Empty

Copyright © Steinberg Media Technologies GmbH. All Rights Reserved. This documentation is under this license.