"Smart pointer" class, deletes objects via the standard C++ delete operator. More...
#include <localpointer.h>
Public Member Functions | |
LocalPointer (T *p=NULL) | |
Constructor takes ownership. | |
~LocalPointer () | |
Destructor deletes the object it owns. | |
void | adoptInstead (T *p) |
Deletes the object it owns, and adopts (takes ownership of) the one passed in. |
"Smart pointer" class, deletes objects via the standard C++ delete operator.
For most methods see the LocalPointerBase base class.
Usage example:
LocalPointer<UnicodeString> s(new UnicodeString((UChar32)0x50005)); int32_t length=s->length(); // 2 UChar lead=s->charAt(0); // 0xd900 if(some condition) { return; } // no need to explicitly delete the pointer s.adoptInstead(new UnicodeString((UChar)0xfffc)); length=s->length(); // 1 // no need to explicitly delete the pointer
Definition at line 186 of file localpointer.h.
icu::LocalPointer< T >::LocalPointer | ( | T * | p = NULL |
) | [inline, explicit] |
Constructor takes ownership.
p | simple pointer to an object that is adopted |
Definition at line 193 of file localpointer.h.
icu::LocalPointer< T >::~LocalPointer | ( | ) | [inline] |
Destructor deletes the object it owns.
Definition at line 198 of file localpointer.h.
void icu::LocalPointer< T >::adoptInstead | ( | T * | p | ) | [inline] |
Deletes the object it owns, and adopts (takes ownership of) the one passed in.
p | simple pointer to an object that is adopted |
Reimplemented from icu::LocalPointerBase< T >.
Definition at line 207 of file localpointer.h.