template <typename T>
class LocalArray
Defined at line 366 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
"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:
Code
LocalArray<UnicodeString> a(new UnicodeString[2]);
a[0].append((char16_t)0x61);
if(some condition) { return; } // no need to explicitly delete the array
a.adoptInstead(new UnicodeString[4]);
a[3].append((char16_t)0x62).append((char16_t)0x63).reverse();
// no need to explicitly delete the array
Public Methods
void LocalArray<T> (T * p)
Constructor takes ownership.
Parameters
Defined at line 375 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
void LocalArray<T> (T * p, UErrorCode & errorCode)
Constructor takes ownership and reports an error if nullptr.
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().
Parameters
Defined at line 389 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
void LocalArray<T> (LocalArray<T> && src)
Move constructor, leaves src with isNull().
Parameters
Defined at line 399 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
void LocalArray<T> (std::unique_ptr<T[]> && p)
Constructs a LocalArray from a C++11 std::unique_ptr of an array type.
The LocalPointer steals the array owned by the std::unique_ptr.
This constructor works via move semantics. If your std::unique_ptr is
in a local variable, you must use std::move.
Parameters
Defined at line 413 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
void ~LocalArray<T> ()
Destructor deletes the array it owns.
ICU 4.4
Defined at line 420 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
LocalArray<T> & operator= (LocalArray<T> && src)
Move assignment operator, leaves src with isNull().
The behavior is undefined if *this and src are the same object.
Parameters
Returns
*this
ICU 56
Defined at line 430 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
LocalArray<T> & operator= (std::unique_ptr<T[]> && p)
Move-assign from an std::unique_ptr to this LocalPointer.
Steals the array from the std::unique_ptr.
Parameters
Returns
*this
ICU 64
Defined at line 445 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
void swap (LocalArray<T> & other)
Swap pointers.
Parameters
Defined at line 455 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
void adoptInstead (T * p)
Deletes the array it owns,
and adopts (takes ownership of) the one passed in.
Parameters
Defined at line 475 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
void adoptInsteadAndCheckErrorCode (T * p, UErrorCode & errorCode)
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 nullptr,
then U_MEMORY_ALLOCATION_ERROR is set,
the current array is deleted, and nullptr is set.
Parameters
Defined at line 494 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
T & operator[] (ptrdiff_t i)
Array item access (writable).
No index bounds check.
Parameters
Returns
reference to the array item
ICU 4.4
Defined at line 512 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
std::unique_ptr<T[]> operator std::unique_ptr<type-parameter-0-0[], std::default_delete<type-parameter-0-0[]> > ()
Conversion operator to a C++11 std::unique_ptr.
Disowns the object and gives it to the returned std::unique_ptr.
This operator works via move semantics. If your LocalPointer is
in a local variable, you must use std::move.
Returns
An std::unique_ptr owning the pointer previously owned by this
icu::LocalPointer.
ICU 64
Defined at line 525 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
Friends
template <typename T>
void LocalArray (LocalArray<T> & p1LocalArray<T> & p2)