Navigation
API > API/Runtime > API/Runtime/Core
TNonNullPtr is a non-nullable pointer to ObjectType that can be used to track references that should never be null. It will never be null during normal operation, but may be uninitialized during object construction and destruction. It supports intrusive optional state so TOptional
| Name | TNonNullPtr |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Templates/NonNullPointer.h |
| Include Path | #include "Templates/NonNullPointer.h" |
Syntax
template<typename ObjectType>
class TNonNullPtr
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Start as uninitialized, so it can be used as a member variable and set during later object initialization | Templates/NonNullPointer.h | ||
TNonNullPtr
(
TYPE_OF_NULLPTR |
Nullptr constructor - not allowed. | Templates/NonNullPointer.h | |
TNonNullPtr
(
ObjectType* InObject |
Constructs a non-null pointer from the provided pointer. Must not be nullptr. | Templates/NonNullPointer.h | |
TNonNullPtr
(
const TNonNullPtr< OtherObjectType >& Other |
Constructs a non-null pointer from another non-null pointer | Templates/NonNullPointer.h | |
| Templates/NonNullPointer.h |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| IntrusiveUnsetOptionalStateType | TNonNullPtr | Templates/NonNullPointer.h |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| bHasIntrusiveUnsetOptionalState | bool | Start - intrusive TOptional |
Templates/NonNullPointer.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| Object | ObjectType * | The object we're holding a reference to. | Templates/NonNullPointer.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
ObjectType * Get() |
Returns the internal pointer | Templates/NonNullPointer.h | |
bool IsInitialized () |
Check to see if a pointer has been initialized, which means it will point to a valid object for the lifecycle of the owning object. | Templates/NonNullPointer.h | |
void ResetToUninitialized () |
WARNING: Hack that can be used under extraordinary circumstances. | Templates/NonNullPointer.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
operator bool() |
Use IsInitialized if needed | Templates/NonNullPointer.h | |
operator ObjectType *() |
Returns the internal pointer | Templates/NonNullPointer.h | |
bool operator!=
(
const TNonNullPtr& Other |
Templates/NonNullPointer.h | ||
bool operator!=
(
OtherObjectType* Other |
Templates/NonNullPointer.h | ||
ObjectType & operator*() |
Dereference operator returns a reference to the object this pointer points to | Templates/NonNullPointer.h | |
TNonNullPtr & operator=
(
const TNonNullPtr< OtherObjectType >& Other |
Assignment operator taking another TNonNullPtr | Templates/NonNullPointer.h | |
TNonNullPtr & operator=
(
ObjectType* InObject |
Assignment operator taking a pointer | Templates/NonNullPointer.h | |
TNonNullPtr & operator=
(
TYPE_OF_NULLPTR |
Assignment operator taking a nullptr - not allowed. | Templates/NonNullPointer.h | |
bool operator==
(
const TNonNullPtr& Other |
Comparison, will also handle default constructed state | Templates/NonNullPointer.h | |
bool operator==
(
OtherObjectType* Other |
Comparison with a raw pointer | Templates/NonNullPointer.h | |
bool operator==
(
FIntrusiveUnsetOptionalState |
Templates/NonNullPointer.h | ||
ObjectType * operator->() |
Arrow operator returns a pointer to this pointer's object | Templates/NonNullPointer.h |