ICU 63.1
63.1
|
"Smart pointer" class, deletes objects via the C++ array delete[] operator. More...
#include <localpointer.h>
Public Member Functions | |
LocalArray (T *p=NULL) | |
Constructor takes ownership. More... | |
LocalArray (T *p, UErrorCode &errorCode) | |
Constructor takes ownership and reports an error if NULL. More... | |
LocalArray (LocalArray< T > &&src) U_NOEXCEPT | |
Move constructor, leaves src with isNull(). More... | |
~LocalArray () | |
Destructor deletes the array it owns. More... | |
LocalArray< T > & | operator= (LocalArray< T > &&src) U_NOEXCEPT |
Move assignment operator, leaves src with isNull(). More... | |
LocalArray< T > & | moveFrom (LocalArray< T > &src) U_NOEXCEPT |
Move assignment, leaves src with isNull(). More... | |
void | swap (LocalArray< T > &other) U_NOEXCEPT |
Swap pointers. More... | |
void | adoptInstead (T *p) |
Deletes the array it owns, and adopts (takes ownership of) the one passed in. More... | |
void | adoptInsteadAndCheckErrorCode (T *p, UErrorCode &errorCode) |
Deletes the array it owns, and adopts (takes ownership of) the one passed in. More... | |
T & | operator[] (ptrdiff_t i) const |
Array item access (writable). More... | |
![]() | |
LocalPointerBase (T *p=NULL) | |
Constructor takes ownership. More... | |
~LocalPointerBase () | |
Destructor deletes the object it owns. More... | |
UBool | isNull () const |
NULL check. More... | |
UBool | isValid () const |
NULL check. More... | |
bool | operator== (const T *other) const |
Comparison with a simple pointer, so that existing code with ==NULL need not be changed. More... | |
bool | operator!= (const T *other) const |
Comparison with a simple pointer, so that existing code with !=NULL need not be changed. More... | |
T * | getAlias () const |
Access without ownership change. More... | |
T & | operator* () const |
Access without ownership change. More... | |
T * | operator-> () const |
Access without ownership change. More... | |
T * | orphan () |
Gives up ownership; the internal pointer becomes NULL. More... | |
void | adoptInstead (T *p) |
Deletes the object it owns, and adopts (takes ownership of) the one passed in. More... | |
Friends | |
void | swap (LocalArray< T > &p1, LocalArray< T > &p2) U_NOEXCEPT |
Non-member LocalArray swap function. More... | |
Additional Inherited Members | |
![]() | |
T * | ptr |
Actual pointer. More... | |
"Smart pointer" class, deletes objects via the C++ array delete[] operator.
For most methods see the LocalPointerBase base class. Adds operator[] for array item access.
Usage example:
Definition at line 333 of file localpointer.h.
|
inlineexplicit |
Constructor takes ownership.
p | simple pointer to an array of T objects that is adopted |
Definition at line 342 of file localpointer.h.
|
inline |
Constructor takes ownership and reports an error if NULL.
This constructor is intended to be used with other-class constructors that may report a failure UErrorCode, so that callers need to check only for U_FAILURE(errorCode) and not also separately for isNull().
p | simple pointer to an array of T objects that is adopted |
errorCode | in/out UErrorCode, set to U_MEMORY_ALLOCATION_ERROR if p==NULL and no other failure code had been set |
Definition at line 356 of file localpointer.h.
References NULL, U_MEMORY_ALLOCATION_ERROR, and U_SUCCESS.
|
inline |
Move constructor, leaves src with isNull().
src | source smart pointer |
Definition at line 366 of file localpointer.h.
References NULL, and icu::LocalPointerBase< T >::ptr.
|
inline |
|
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 |
Definition at line 427 of file localpointer.h.
|
inline |
Deletes the array it owns, and adopts (takes ownership of) the one passed in.
If U_FAILURE(errorCode), then the current array is retained and the new one deleted.
If U_SUCCESS(errorCode) but the input pointer is NULL, then U_MEMORY_ALLOCATION_ERROR is set, the current array is deleted, and NULL is set.
p | simple pointer to an array of T objects that is adopted |
errorCode | in/out UErrorCode, set to U_MEMORY_ALLOCATION_ERROR if p==NULL and no other failure code had been set |
Definition at line 446 of file localpointer.h.
References NULL, U_MEMORY_ALLOCATION_ERROR, and U_SUCCESS.
|
inline |
Move assignment, leaves src with isNull().
The behavior is undefined if *this and src are the same object.
Can be called explicitly, does not need C++11 support.
src | source smart pointer |
Definition at line 396 of file localpointer.h.
References NULL, and icu::LocalPointerBase< T >::ptr.
|
inline |
Move assignment operator, leaves src with isNull().
The behavior is undefined if *this and src are the same object.
src | source smart pointer |
Definition at line 383 of file localpointer.h.
|
inline |
Array item access (writable).
No index bounds check.
i | array index |
Definition at line 464 of file localpointer.h.
|
inline |
Swap pointers.
other | other smart pointer |
Definition at line 407 of file localpointer.h.
References icu::LocalPointerBase< T >::ptr.
|
friend |
Non-member LocalArray swap function.
p1 | will get p2's pointer |
p2 | will get p1's pointer |
Definition at line 418 of file localpointer.h.