template <typename T>
class LocalPointer
Defined at line 191 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
"Smart pointer" class, deletes objects via the standard C++ delete operator.
For most methods see the LocalPointerBase base class.
Usage example:
Code
LocalPointer<UnicodeString> s(new UnicodeString((UChar32)0x50005));
int32_t length=s->length(); // 2
char16_t lead=s->charAt(0); // 0xd900
if(some condition) { return; } // no need to explicitly delete the pointer
s.adoptInstead(new UnicodeString((char16_t)0xfffc));
length=s->length(); // 1
// no need to explicitly delete the pointer
Public Methods
void LocalPointer<T> (T * p)
Constructor takes ownership.
Parameters
Defined at line 200 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
void LocalPointer<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 214 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
void LocalPointer<T> (LocalPointer<T> && src)
Move constructor, leaves src with isNull().
Parameters
Defined at line 224 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
void LocalPointer<T> (std::unique_ptr<T> && p)
Constructs a LocalPointer from a C++11 std::unique_ptr.
The LocalPointer steals the object 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 238 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
void ~LocalPointer<T> ()
Destructor deletes the object it owns.
ICU 4.4
Defined at line 245 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
LocalPointer<T> & operator= (LocalPointer<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 255 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
LocalPointer<T> & operator= (std::unique_ptr<T> && p)
Move-assign from an std::unique_ptr to this LocalPointer.
Steals the pointer from the std::unique_ptr.
Parameters
Returns
*this
ICU 64
Defined at line 270 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
void swap (LocalPointer<T> & other)
Swap pointers.
Parameters
Defined at line 280 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
void adoptInstead (T * p)
Deletes the object it owns,
and adopts (takes ownership of) the one passed in.
Parameters
Defined at line 300 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
void adoptInsteadAndCheckErrorCode (T * p, UErrorCode & errorCode)
Deletes the object it owns,
and adopts (takes ownership of) the one passed in.
If U_FAILURE(errorCode), then the current object 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 object is deleted, and nullptr is set.
Parameters
Defined at line 319 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 342 of file ../../third_party/icu/default/source/common/unicode/localpointer.h
Friends
template <typename T>
void LocalPointer (LocalPointer<T> & p1LocalPointer<T> & p2)