A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1LocalPointer.html below:

ICU 77.1: icu::LocalPointer< T > Class Template Reference

"Smart pointer" class, deletes objects via the standard C++ delete operator. More...

#include <localpointer.h>

static void *  operator new (size_t)=delete   static void *  operator new[] (size_t)=delete   T *  ptr   Actual pointer. More...
  template<typename T>
class icu::LocalPointer< T >

"Smart pointer" class, deletes objects via the standard C++ delete operator.

For most methods see the LocalPointerBase base class.

Usage example:

LocalPointer<UnicodeString> s(

new

UnicodeString((

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.

See also
LocalPointerBase
Stable:
ICU 4.4

Definition at line 191 of file localpointer.h.

◆ LocalPointer() [1/4]

Constructor takes ownership.

Parameters
p simple pointer to an object that is adopted
Stable:
ICU 4.4

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().

Parameters
p simple pointer to an object that is adopted errorCode in/out UErrorCode, set to U_MEMORY_ALLOCATION_ERROR if p==nullptr and no other failure code had been set
Stable:
ICU 55

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.

Parameters
p The std::unique_ptr from which the pointer will be stolen.
Stable:
ICU 64

Definition at line 238 of file localpointer.h.

◆ ~LocalPointer() ◆ adoptInstead()

Deletes the object it owns, and adopts (takes ownership of) the one passed in.

Parameters
p simple pointer to an object that is adopted
Stable:
ICU 4.4

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.

Parameters
p simple pointer to an object that is adopted errorCode in/out UErrorCode, set to U_MEMORY_ALLOCATION_ERROR if p==nullptr and no other failure code had been set
Stable:
ICU 55

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.

Returns
An std::unique_ptr owning the pointer previously owned by this icu::LocalPointer.
Stable:
ICU 64

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.

Parameters
p The std::unique_ptr from which the pointer will be stolen.
Returns
*this
Stable:
ICU 64

Definition at line 270 of file localpointer.h.

◆ swap() ◆ swap

The 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