"Smart pointer" class, deletes objects via the standard C++ delete operator. More...
#include <localpointer.h>
"Smart pointer" class, deletes objects via the standard C++ delete operator.
For most methods see the LocalPointerBase base class.
Usage example:
LocalPointer<UnicodeString> s(
newUnicodeString((
UChar32)0x50005));
int32_t length=s->length();
char16_t lead=s->charAt(0);
if(some condition) { return; }
s.adoptInstead(new UnicodeString((char16_t)0xfffc));
length=s->length();
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition at line 191 of file localpointer.h.
◆ LocalPointer() [1/4]Constructor takes ownership.
Definition at line 200 of file localpointer.h.
◆ LocalPointer() [2/4]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().
Definition at line 214 of file localpointer.h.
References U_MEMORY_ALLOCATION_ERROR, and U_SUCCESS.
◆ LocalPointer() [3/4] ◆ LocalPointer() [4/4]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.
Definition at line 238 of file localpointer.h.
◆ ~LocalPointer() ◆ adoptInstead()Deletes the object it owns, and adopts (takes ownership of) the one passed in.
Definition at line 300 of file localpointer.h.
◆ adoptInsteadAndCheckErrorCode()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.
Definition at line 319 of file localpointer.h.
References U_MEMORY_ALLOCATION_ERROR, and U_SUCCESS.
◆ operator std::unique_ptr< T >()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 342 of file localpointer.h.
◆ operator=() [1/2] ◆ operator=() [2/2]Move-assign from an std::unique_ptr to this LocalPointer.
Steals the pointer from the std::unique_ptr.
Definition at line 270 of file localpointer.h.
◆ swap() ◆ swapThe documentation for this class was generated from the following file:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4