ICU 65.1
65.1
|
"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. More... | |
LocalPointer (T *p, UErrorCode &errorCode) | |
Constructor takes ownership and reports an error if NULL. More... | |
LocalPointer (LocalPointer< T > &&src) U_NOEXCEPT | |
Move constructor, leaves src with isNull(). More... | |
LocalPointer (std::unique_ptr< T > &&p) | |
Constructs a LocalPointer from a C++11 std::unique_ptr. More... | |
~LocalPointer () | |
Destructor deletes the object it owns. More... | |
LocalPointer< T > & | operator= (LocalPointer< T > &&src) U_NOEXCEPT |
Move assignment operator, leaves src with isNull(). More... | |
LocalPointer< T > & | operator= (std::unique_ptr< T > &&p) U_NOEXCEPT |
Move-assign from an std::unique_ptr to this LocalPointer. More... | |
void | swap (LocalPointer< T > &other) U_NOEXCEPT |
Swap pointers. More... | |
void | adoptInstead (T *p) |
Deletes the object it owns, and adopts (takes ownership of) the one passed in. More... | |
void | adoptInsteadAndCheckErrorCode (T *p, UErrorCode &errorCode) |
Deletes the object it owns, and adopts (takes ownership of) the one passed in. More... | |
operator std::unique_ptr< T > () && | |
Conversion operator to a C++11 std::unique_ptr. More... | |
Public Member Functions inherited from icu::LocalPointerBase< T > | |
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 (LocalPointer< T > &p1, LocalPointer< T > &p2) U_NOEXCEPT |
Non-member LocalPointer swap function. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from icu::LocalPointerBase< T > | |
static void * | operator new (size_t)=delete |
static void * | operator new[] (size_t)=delete |
Protected Attributes inherited from icu::LocalPointerBase< T > | |
T * | ptr |
Actual pointer. More... | |
"Smart pointer" class, deletes objects via the standard C++ delete operator.
For most methods see the LocalPointerBase base class.
Usage example:
Definition at line 191 of file localpointer.h.
|
inlineexplicit |
Constructor takes ownership.
p | simple pointer to an object that is adopted |
Definition at line 200 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 object 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 214 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 224 of file localpointer.h.
References NULL, and icu::LocalPointerBase< T >::ptr.
|
inlineexplicit |
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.
p | The std::unique_ptr from which the pointer will be stolen. |
Definition at line 239 of file localpointer.h.
|
inline |
Destructor deletes the object it owns.
Definition at line 247 of file localpointer.h.
|
inline |
Deletes the object it owns, and adopts (takes ownership of) the one passed in.
p | simple pointer to an object that is adopted |
Definition at line 304 of file localpointer.h.
|
inline |
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 NULL, then U_MEMORY_ALLOCATION_ERROR is set, the current object is deleted, and NULL is set.
p | simple pointer to an object 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 323 of file localpointer.h.
References NULL, U_MEMORY_ALLOCATION_ERROR, and U_SUCCESS.
|
inline |
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.
Definition at line 347 of file localpointer.h.
|
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 257 of file localpointer.h.
References NULL, and icu::LocalPointerBase< T >::ptr.
|
inline |
Move-assign from an std::unique_ptr to this LocalPointer.
Steals the pointer from the std::unique_ptr.
p | The std::unique_ptr from which the pointer will be stolen. |
Definition at line 273 of file localpointer.h.
|
inline |
Swap pointers.
other | other smart pointer |
Definition at line 284 of file localpointer.h.
References icu::LocalPointerBase< T >::ptr.
|
friend |
Non-member LocalPointer swap function.
p1 | will get p2's pointer |
p2 | will get p1's pointer |
Definition at line 295 of file localpointer.h.