engine
 
载入中...
搜索中...
未找到
Public 成员函数 | 友元 | 所有成员列表
TSharedPtr< ObjectType, Mode > 模板类 参考

TSharedPtr is a non-intrusive reference-counted authoritative object pointer. 更多...

#include <SharedPointer.h>

Public 成员函数

FORCEINLINE ObjectType * Get () const
 Returns the object referenced by this pointer, or nullptr if no object is reference 更多...
 
FORCEINLINE const int32 GetSharedReferenceCount () const
 Returns the number of shared references to this object (including this reference.) IMPORTANT: Not necessarily fast! Should only be used for debugging purposes! 更多...
 
FORCEINLINE const bool IsUnique () const
 Returns true if this is the only shared reference to this object. 更多...
 
FORCEINLINE const bool IsValid () const
 Checks to see if this shared pointer is actually pointing to an object 更多...
 
FORCEINLINE operator bool () const
 Checks to see if this shared pointer is actually pointing to an object 更多...
 
FORCEINLINE FMakeReferenceTo< ObjectType >::Type operator* () const
 Dereference operator returns a reference to the object this shared pointer points to 更多...
 
FORCEINLINE ObjectType * operator-> () const
 Arrow operator returns a pointer to the object this shared pointer references 更多...
 
FORCEINLINE TSharedPtr & operator= (SharedPointerInternals::FNullTag *)
 Assignment to a nullptr pointer. 更多...
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr & operator= (SharedPointerInternals::FRawPtrProxy< OtherType > const &InRawPtrProxy)
 Assignment operator replaces this shared pointer with the specified shared pointer. 更多...
 
FORCEINLINE TSharedPtr & operator= (TSharedPtr const &InSharedPtr)
 Assignment operator replaces this shared pointer with the specified shared pointer. 更多...
 
FORCEINLINE void Reset ()
 Resets this shared pointer, removing a reference to the object. 更多...
 
FORCEINLINE TSharedRef< ObjectType, Mode > ToSharedRef () &&
 Converts a shared pointer to a shared reference. 更多...
 
FORCEINLINE TSharedRef< ObjectType, Mode > ToSharedRef () const &
 Converts a shared pointer to a shared reference. 更多...
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr (OtherType *InObject)
 Constructs a shared pointer that owns the specified object. 更多...
 
template<typename OtherType , typename DeleterType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr (OtherType *InObject, DeleterType &&InDeleter)
 Constructs a shared pointer that owns the specified object. 更多...
 
FORCEINLINE TSharedPtr (SharedPointerInternals::FNullTag *=nullptr)
 Constructs an empty shared pointer
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr (SharedPointerInternals::FRawPtrProxy< OtherType > const &InRawPtrProxy)
 Constructs a shared pointer using a proxy reference to a raw pointer. 更多...
 
template<typename OtherType >
FORCEINLINE TSharedPtr (TSharedPtr< OtherType, Mode > &&OtherSharedPtr, ObjectType *InObject)
 Aliasing constructor used to create a shared pointer which shares its reference count with another shared object, but pointing to a different object, typically a subobject. 更多...
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr (TSharedPtr< OtherType, Mode > const &InSharedPtr)
 Constructs a shared pointer as a shared reference to an existing shared pointer's object. 更多...
 
template<typename OtherType >
FORCEINLINE TSharedPtr (TSharedPtr< OtherType, Mode > const &InSharedPtr, SharedPointerInternals::FConstCastTag)
 Special constructor used internally to cast a 'const' shared pointer a 'mutable' pointer. 更多...
 
template<typename OtherType >
FORCEINLINE TSharedPtr (TSharedPtr< OtherType, Mode > const &InSharedPtr, SharedPointerInternals::FStaticCastTag)
 Special constructor used internally to statically cast one shared pointer type to another. 更多...
 
template<typename OtherType >
FORCEINLINE TSharedPtr (TSharedPtr< OtherType, Mode > const &OtherSharedPtr, ObjectType *InObject)
 Aliasing constructor used to create a shared pointer which shares its reference count with another shared object, but pointing to a different object, typically a subobject. 更多...
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr (TSharedRef< OtherType, Mode > const &InSharedRef)
 Implicitly converts a shared reference to a shared pointer, adding a reference to the object. 更多...
 
template<typename OtherType >
FORCEINLINE TSharedPtr (TSharedRef< OtherType, Mode > const &OtherSharedRef, ObjectType *InObject)
 Aliasing constructor used to create a shared pointer which shares its reference count with another shared object, but pointing to a different object, typically a subobject. 更多...
 

友元

uint32 GetTypeHash (const TSharedPtr< ObjectType, Mode > &InSharedPtr)
 Computes a hash code for this object 更多...
 
template<class OtherType , ESPMode OtherMode>
class TSharedFromThis
 
template<class OtherType , ESPMode OtherMode>
class TSharedRef
 
template<class OtherType , ESPMode OtherMode>
class TWeakPtr
 

详细描述

template<class ObjectType, ESPMode Mode>
class TSharedPtr< ObjectType, Mode >

TSharedPtr is a non-intrusive reference-counted authoritative object pointer.

This shared pointer will be conditionally thread-safe when the optional Mode template argument is set to ThreadSafe.

示例
/github/workspace/Engine/Source/Runtime/UMG/Public/Components/Widget.h.

构造及析构函数说明

◆ TSharedPtr() [1/10]

template<class ObjectType , ESPMode Mode>
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr< ObjectType, Mode >::TSharedPtr ( OtherType *  InObject)
inlineexplicit

Constructs a shared pointer that owns the specified object.

Note that passing nullptr here will still create a tracked reference to a nullptr pointer. (Consistent with std::shared_ptr)

参数
InObjectObject this shared pointer to retain a reference to

◆ TSharedPtr() [2/10]

template<class ObjectType , ESPMode Mode>
template<typename OtherType , typename DeleterType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr< ObjectType, Mode >::TSharedPtr ( OtherType *  InObject,
DeleterType &&  InDeleter 
)
inline

Constructs a shared pointer that owns the specified object.

Note that passing nullptr here will still create a tracked reference to a nullptr pointer. (Consistent with std::shared_ptr)

参数
InObjectObject this shared pointer to retain a reference to
InDeleterDeleter object used to destroy the object when it is no longer referenced.

◆ TSharedPtr() [3/10]

template<class ObjectType , ESPMode Mode>
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr< ObjectType, Mode >::TSharedPtr ( SharedPointerInternals::FRawPtrProxy< OtherType > const &  InRawPtrProxy)
inline

Constructs a shared pointer using a proxy reference to a raw pointer.

(See MakeShareable())

参数
InRawPtrProxyProxy raw pointer that contains the object that the new shared pointer will reference

◆ TSharedPtr() [4/10]

template<class ObjectType , ESPMode Mode>
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr< ObjectType, Mode >::TSharedPtr ( TSharedPtr< OtherType, Mode > const &  InSharedPtr)
inline

Constructs a shared pointer as a shared reference to an existing shared pointer's object.

This constructor is needed so that we can implicitly upcast to base classes.

参数
InSharedPtrThe shared pointer whose object we should create an additional reference to

◆ TSharedPtr() [5/10]

template<class ObjectType , ESPMode Mode>
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr< ObjectType, Mode >::TSharedPtr ( TSharedRef< OtherType, Mode > const &  InSharedRef)
inline

Implicitly converts a shared reference to a shared pointer, adding a reference to the object.

NOTE: We allow an implicit conversion from TSharedRef to TSharedPtr because it's always a safe conversion.

参数
InSharedRefThe shared reference that will be converted to a shared pointer

◆ TSharedPtr() [6/10]

template<class ObjectType , ESPMode Mode>
template<typename OtherType >
FORCEINLINE TSharedPtr< ObjectType, Mode >::TSharedPtr ( TSharedPtr< OtherType, Mode > const &  InSharedPtr,
SharedPointerInternals::FStaticCastTag   
)
inline

Special constructor used internally to statically cast one shared pointer type to another.

You should never call this constructor directly. Instead, use the StaticCastSharedPtr() function. This constructor creates a shared pointer as a shared reference to an existing shared pointer after statically casting that pointer's object. This constructor is needed for static casts.

参数
InSharedPtrThe shared pointer whose object we should create an additional reference to

◆ TSharedPtr() [7/10]

template<class ObjectType , ESPMode Mode>
template<typename OtherType >
FORCEINLINE TSharedPtr< ObjectType, Mode >::TSharedPtr ( TSharedPtr< OtherType, Mode > const &  InSharedPtr,
SharedPointerInternals::FConstCastTag   
)
inline

Special constructor used internally to cast a 'const' shared pointer a 'mutable' pointer.

You should never call this constructor directly. Instead, use the ConstCastSharedPtr() function. This constructor creates a shared pointer as a shared reference to an existing shared pointer after const casting that pointer's object. This constructor is needed for const casts.

参数
InSharedPtrThe shared pointer whose object we should create an additional reference to

◆ TSharedPtr() [8/10]

template<class ObjectType , ESPMode Mode>
template<typename OtherType >
FORCEINLINE TSharedPtr< ObjectType, Mode >::TSharedPtr ( TSharedPtr< OtherType, Mode > const &  OtherSharedPtr,
ObjectType *  InObject 
)
inline

Aliasing constructor used to create a shared pointer which shares its reference count with another shared object, but pointing to a different object, typically a subobject.

参数
OtherSharedPtrThe shared pointer whose reference count should be shared.
InObjectThe object pointer to use (instead of the incoming shared pointer's object)

◆ TSharedPtr() [9/10]

template<class ObjectType , ESPMode Mode>
template<typename OtherType >
FORCEINLINE TSharedPtr< ObjectType, Mode >::TSharedPtr ( TSharedPtr< OtherType, Mode > &&  OtherSharedPtr,
ObjectType *  InObject 
)
inline

Aliasing constructor used to create a shared pointer which shares its reference count with another shared object, but pointing to a different object, typically a subobject.

参数
OtherSharedPtrThe shared pointer whose reference count should be shared.
InObjectThe object pointer to use (instead of the incoming shared pointer's object)

◆ TSharedPtr() [10/10]

template<class ObjectType , ESPMode Mode>
template<typename OtherType >
FORCEINLINE TSharedPtr< ObjectType, Mode >::TSharedPtr ( TSharedRef< OtherType, Mode > const &  OtherSharedRef,
ObjectType *  InObject 
)
inline

Aliasing constructor used to create a shared pointer which shares its reference count with another shared object, but pointing to a different object, typically a subobject.

参数
OtherSharedRefThe shared reference whose reference count should be shared.
InObjectThe object pointer to use (instead of the incoming shared pointer's object)

成员函数说明

◆ Get()

template<class ObjectType , ESPMode Mode>
FORCEINLINE ObjectType * TSharedPtr< ObjectType, Mode >::Get ( ) const
inline

Returns the object referenced by this pointer, or nullptr if no object is reference

返回
The object owned by this shared pointer, or nullptr

◆ GetSharedReferenceCount()

template<class ObjectType , ESPMode Mode>
FORCEINLINE const int32 TSharedPtr< ObjectType, Mode >::GetSharedReferenceCount ( ) const
inline

Returns the number of shared references to this object (including this reference.) IMPORTANT: Not necessarily fast! Should only be used for debugging purposes!

返回
Number of shared references to the object (including this reference.)

◆ IsUnique()

template<class ObjectType , ESPMode Mode>
FORCEINLINE const bool TSharedPtr< ObjectType, Mode >::IsUnique ( ) const
inline

Returns true if this is the only shared reference to this object.

Note that there may be outstanding weak references left. IMPORTANT: Not necessarily fast! Should only be used for debugging purposes!

返回
True if there is only one shared reference to the object, and this is it!

◆ IsValid()

template<class ObjectType , ESPMode Mode>
FORCEINLINE const bool TSharedPtr< ObjectType, Mode >::IsValid ( ) const
inline

Checks to see if this shared pointer is actually pointing to an object

返回
True if the shared pointer is valid and can be dereferenced

◆ operator bool()

template<class ObjectType , ESPMode Mode>
FORCEINLINE TSharedPtr< ObjectType, Mode >::operator bool ( ) const
inlineexplicit

Checks to see if this shared pointer is actually pointing to an object

返回
True if the shared pointer is valid and can be dereferenced

◆ operator*()

template<class ObjectType , ESPMode Mode>
FORCEINLINE FMakeReferenceTo< ObjectType >::Type TSharedPtr< ObjectType, Mode >::operator* ( ) const
inline

Dereference operator returns a reference to the object this shared pointer points to

返回
Reference to the object

◆ operator->()

template<class ObjectType , ESPMode Mode>
FORCEINLINE ObjectType * TSharedPtr< ObjectType, Mode >::operator-> ( ) const
inline

Arrow operator returns a pointer to the object this shared pointer references

返回
Returns a pointer to the object referenced by this shared pointer

◆ operator=() [1/3]

template<class ObjectType , ESPMode Mode>
FORCEINLINE TSharedPtr & TSharedPtr< ObjectType, Mode >::operator= ( SharedPointerInternals::FNullTag *  )
inline

Assignment to a nullptr pointer.

The object currently referenced by this shared pointer will no longer be referenced and will be deleted if there are no other referencers.

◆ operator=() [2/3]

template<class ObjectType , ESPMode Mode>
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr & TSharedPtr< ObjectType, Mode >::operator= ( SharedPointerInternals::FRawPtrProxy< OtherType > const &  InRawPtrProxy)
inline

Assignment operator replaces this shared pointer with the specified shared pointer.

The object currently referenced by this shared pointer will no longer be referenced and will be deleted if there are no other referencers.

参数
InRawPtrProxyProxy object used to assign the object (see MakeShareable helper function)

◆ operator=() [3/3]

template<class ObjectType , ESPMode Mode>
FORCEINLINE TSharedPtr & TSharedPtr< ObjectType, Mode >::operator= ( TSharedPtr< ObjectType, Mode > const &  InSharedPtr)
inline

Assignment operator replaces this shared pointer with the specified shared pointer.

The object currently referenced by this shared pointer will no longer be referenced and will be deleted if there are no other referencers.

参数
InSharedPtrShared pointer to replace with

◆ Reset()

template<class ObjectType , ESPMode Mode>
FORCEINLINE void TSharedPtr< ObjectType, Mode >::Reset ( )
inline

Resets this shared pointer, removing a reference to the object.

If there are no other shared references to the object then it will be destroyed.

◆ ToSharedRef() [1/2]

template<class ObjectType , ESPMode Mode>
FORCEINLINE TSharedRef< ObjectType, Mode > TSharedPtr< ObjectType, Mode >::ToSharedRef ( ) &&
inline

Converts a shared pointer to a shared reference.

The pointer must be valid or an assertion will trigger.

返回
Reference to the object

◆ ToSharedRef() [2/2]

template<class ObjectType , ESPMode Mode>
FORCEINLINE TSharedRef< ObjectType, Mode > TSharedPtr< ObjectType, Mode >::ToSharedRef ( ) const &
inline

Converts a shared pointer to a shared reference.

The pointer must be valid or an assertion will trigger.

返回
Reference to the object

友元及相关函数文档

◆ GetTypeHash

template<class ObjectType , ESPMode Mode>
uint32 GetTypeHash ( const TSharedPtr< ObjectType, Mode > &  InSharedPtr)
friend

Computes a hash code for this object

参数
InSharedPtrShared pointer to compute hash code for
返回
Hash code value

该类的文档由以下文件生成: