Movatterモバイル変換


[0]ホーム

URL:


ICU 78.1  78.1
Public Member Functions |Static Public Member Functions |Protected Attributes
icu::LocalPointerBase< T > Class Template Reference

"Smart pointer" base class; do not use directly: useLocalPointer etc.More...

#include <localpointer.h>

Inheritance diagram for icu::LocalPointerBase< T >:

Public Member Functions

 LocalPointerBase (T *p=nullptr)
 Constructor takes ownership.More...
 
 ~LocalPointerBase ()
 Destructor deletes the object it owns.More...
 
UBool isNull () const
 nullptr check.More...
 
UBool isValid () const
 nullptr check.More...
 
bool operator== (const T *other) const
 Comparison with a simple pointer, so that existing code with ==nullptr need not be changed.More...
 
bool operator!= (const T *other) const
 Comparison with a simple pointer, so that existing code with !=nullptr 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 nullptr.More...
 
void adoptInstead (T *p)
 Deletes the object it owns, and adopts (takes ownership of) the one passed in.More...
 

Static Public Member Functions

static void * operator new (size_t)=delete
 
static void * operator new[] (size_t)=delete
 
static void * operator new (size_t, void *)=delete
 

Protected Attributes

T * ptr
 Actual pointer.More...
 

Detailed Description

template<typename T>
class icu::LocalPointerBase< T >

"Smart pointer" base class; do not use directly: useLocalPointer etc.

Base class for smart pointer classes that do not throw exceptions.

Do not use this base class directly, since it does not delete its pointer. A subclass must implement methods that delete the pointer: Destructor andadoptInstead().

There is no operator T *() provided because the programmer must decide whether to usegetAlias() (without transfer of ownership) ororphan() (with transfer of ownership and NULLing of the pointer).

See also
LocalPointer
LocalArray
U_DEFINE_LOCAL_OPEN_POINTER
Stable:
ICU 4.4

Definition at line68 of filelocalpointer.h.

Constructor & Destructor Documentation

◆ LocalPointerBase()

template<typename T >
icu::LocalPointerBase< T >::LocalPointerBase(T * p =nullptr)
inlineexplicit

Constructor takes ownership.

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

Definition at line80 of filelocalpointer.h.

◆ ~LocalPointerBase()

template<typename T >
icu::LocalPointerBase< T >::~LocalPointerBase()
inline

Destructor deletes the object it owns.

Subclass must override: Base class does nothing.

Stable:
ICU 4.4

Definition at line86 of filelocalpointer.h.

Member Function Documentation

◆ adoptInstead()

template<typename T >
voidicu::LocalPointerBase< T >::adoptInstead(T * p)
inline

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

Subclass must override: Base class does not delete the object.

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

Definition at line151 of filelocalpointer.h.

◆ getAlias()

template<typename T >
T*icu::LocalPointerBase< T >::getAlias() const
inline

Access without ownership change.

Returns
the pointer value
Stable:
ICU 4.4

Definition at line120 of filelocalpointer.h.

◆ isNull()

template<typename T >
UBoolicu::LocalPointerBase< T >::isNull() const
inline

nullptr check.

Returns
true if ==nullptr
Stable:
ICU 4.4

Definition at line92 of filelocalpointer.h.

Referenced byicu::Locale::getKeywords(), andicu::Locale::getUnicodeKeywords().

◆ isValid()

template<typename T >
UBoolicu::LocalPointerBase< T >::isValid() const
inline

nullptr check.

Returns
true if !=nullptr
Stable:
ICU 4.4

Definition at line98 of filelocalpointer.h.

◆ operator!=()

template<typename T >
boolicu::LocalPointerBase< T >::operator!=(const T * other) const
inline

Comparison with a simple pointer, so that existing code with !=nullptr need not be changed.

Parameters
othersimple pointer for comparison
Returns
true if this pointer value differs from other
Stable:
ICU 4.4

Definition at line114 of filelocalpointer.h.

◆ operator*()

template<typename T >
T&icu::LocalPointerBase< T >::operator*() const
inline

Access without ownership change.

Returns
the pointer value as a reference
Stable:
ICU 4.4

Definition at line126 of filelocalpointer.h.

◆ operator->()

template<typename T >
T*icu::LocalPointerBase< T >::operator->() const
inline

Access without ownership change.

Returns
the pointer value
Stable:
ICU 4.4

Definition at line132 of filelocalpointer.h.

◆ operator==()

template<typename T >
boolicu::LocalPointerBase< T >::operator==(const T * other) const
inline

Comparison with a simple pointer, so that existing code with ==nullptr need not be changed.

Parameters
othersimple pointer for comparison
Returns
true if this pointer value equals other
Stable:
ICU 4.4

Definition at line106 of filelocalpointer.h.

◆ orphan()

template<typename T >
T*icu::LocalPointerBase< T >::orphan()
inline

Gives up ownership; the internal pointer becomes nullptr.

Returns
the pointer value; caller becomes responsible for deleting the object
Stable:
ICU 4.4

Definition at line139 of filelocalpointer.h.

Field Documentation

◆ ptr

template<typename T >
T*icu::LocalPointerBase< T >::ptr
protected

Actual pointer.

Internal:
Do not use. This API is for internal use only.

Definition at line160 of filelocalpointer.h.

Referenced byicu::LocalArray< T >::LocalArray(),icu::LocalPointer< T >::LocalPointer(),icu::LocalArray< T >::operator=(),icu::LocalPointer< T >::operator=(),icu::LocalArray< T >::swap(), andicu::LocalPointer< T >::swap().


The documentation for this class was generated from the following file:

Generated by doxygen 1.9.1
[8]ページ先頭

©2009-2025 Movatter.jp