#include <localpointer.h>
Inheritance diagram for icu::LocalArray< T >:
Public Member Functions | |
LocalArray (T *p=NULL) | |
Constructor takes ownership. | |
~LocalArray () | |
Destructor deletes the array it owns. | |
void | adoptInstead (T *p) |
Deletes the array it owns, and adopts (takes ownership of) the one passed in. | |
T & | operator[] (ptrdiff_t i) const |
Array item access (writable). |
For most methods see the LocalPointerBase base class. Adds operator[] for array item access.
Usage example:
LocalArray<UnicodeString> a(new UnicodeString[2]); a[0].append((UChar)0x61); if(some condition) { return; } // no need to explicitly delete the array a.adoptInstead(new UnicodeString[4]); a[3].append((UChar)0x62).append((UChar)0x63).reverse(); // no need to explicitly delete the array
Definition at line 232 of file localpointer.h.
icu::LocalArray< T >::LocalArray | ( | T * | p = NULL |
) | [inline, explicit] |
Constructor takes ownership.
p | simple pointer to an array of T objects that is adopted |
Definition at line 239 of file localpointer.h.
icu::LocalArray< T >::~LocalArray | ( | ) | [inline] |
void icu::LocalArray< T >::adoptInstead | ( | T * | p | ) | [inline] |
Deletes the array it owns, and adopts (takes ownership of) the one passed in.
p | simple pointer to an array of T objects that is adopted |
Reimplemented from icu::LocalPointerBase< T >.
Definition at line 253 of file localpointer.h.
T& icu::LocalArray< T >::operator[] | ( | ptrdiff_t | i | ) | const [inline] |
Array item access (writable).
No index bounds check.
i | array index |
Definition at line 264 of file localpointer.h.