UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TOptional< OptionalType > Struct Template Reference

#include <Optional.h>

+ Inheritance diagram for TOptional< OptionalType >:

Public Types

using ElementType = OptionalType
 

Public Member Functions

constexpr TOptional (const OptionalType &InValue)
 
constexpr TOptional (OptionalType &&InValue)
 
template<typename... ArgTypes>
constexpr TOptional (EInPlace, ArgTypes &&... Args)
 
constexpr TOptional (FNullOpt)
 
constexpr TOptional ()
 
constexpr TOptional ()
 
constexpr ~TOptional ()=default
 
 TOptional (const TOptional &Other)
 
 TOptional (TOptional &&Other)
 
TOptionaloperator= (const TOptional &Other)
 
TOptionaloperator= (TOptional &&Other)
 
TOptionaloperator= (const OptionalType &InValue)
 
TOptionaloperator= (OptionalType &&InValue)
 
void Reset ()
 
template<typename... ArgsType>
OptionalTypeEmplace (ArgsType &&... Args)
 
void Serialize (FArchive &Ar)
 
UE_FORCEINLINE_HINT constexpr operator bool () const
 
constexpr OptionalTypeGetValue ()
 
UE_FORCEINLINE_HINT constexpr const OptionalTypeGetValue () const
 
constexpr OptionalTypeoperator-> ()
 
UE_FORCEINLINE_HINT constexpr const OptionalTypeoperator-> () const
 
constexpr OptionalTypeoperator* ()
 
UE_FORCEINLINE_HINT constexpr const OptionalTypeoperator* () const
 
constexpr const OptionalTypeGet (const OptionalType &DefaultValue UE_LIFETIMEBOUND) const UE_LIFETIMEBOUND
 
constexpr OptionalTypeGetPtrOrNull ()
 
UE_FORCEINLINE_HINT constexpr const OptionalTypeGetPtrOrNull () const
 
constexpr bool IsSet () const
 

Friends

constexpr bool operator== (const TOptional &Lhs, const TOptional &Rhs)
 
constexpr bool operator!= (const TOptional &Lhs, const TOptional &Rhs)
 

Detailed Description

template<typename OptionalType>
struct TOptional< OptionalType >

When we have an optional value IsSet() returns true, and GetValue() is meaningful. Otherwise GetValue() is not meaningful.

Examples
/work/Engine/Source/Runtime/UMG/Public/Components/Widget.h.

Member Typedef Documentation

◆ ElementType

template<typename OptionalType >
using TOptional< OptionalType >::ElementType = OptionalType

Constructor & Destructor Documentation

◆ TOptional() [1/8]

template<typename OptionalType >
constexpr TOptional< OptionalType >::TOptional ( const OptionalType InValue)
inlineconstexpr

Construct an OptionalType with a valid value.

◆ TOptional() [2/8]

template<typename OptionalType >
constexpr TOptional< OptionalType >::TOptional ( OptionalType &&  InValue)
inlineconstexpr

◆ TOptional() [3/8]

template<typename OptionalType >
template<typename... ArgTypes>
constexpr TOptional< OptionalType >::TOptional ( EInPlace  ,
ArgTypes &&...  Args 
)
inlineexplicitconstexpr

◆ TOptional() [4/8]

Construct an OptionalType with an invalid value.

◆ TOptional() [5/8]

Construct an OptionalType intrusively with no value; i.e. unset

◆ TOptional() [6/8]

Construct an OptionalType with no value; i.e. unset

◆ ~TOptional()

template<typename OptionalType >
constexpr TOptional< OptionalType >::~TOptional ( )
constexprdefault

◆ TOptional() [7/8]

template<typename OptionalType >
TOptional< OptionalType >::TOptional ( const TOptional< OptionalType > &  Other)
inline

Copy/Move construction

◆ TOptional() [8/8]

Member Function Documentation

◆ Emplace()

template<typename OptionalType >
template<typename... ArgsType>
OptionalType & TOptional< OptionalType >::Emplace ( ArgsType &&...  Args)
inline

◆ Get()

template<typename OptionalType >
constexpr const OptionalType & TOptional< OptionalType >::Get ( const OptionalType &DefaultValue  UE_LIFETIMEBOUND) const
inlineconstexpr
Returns
The optional value when set; DefaultValue otherwise.

◆ GetPtrOrNull() [1/2]

template<typename OptionalType >
constexpr OptionalType * TOptional< OptionalType >::GetPtrOrNull ( )
inlineconstexpr
Returns
A pointer to the optional value when set, nullptr otherwise.

◆ GetPtrOrNull() [2/2]

template<typename OptionalType >
UE_FORCEINLINE_HINT constexpr const OptionalType * TOptional< OptionalType >::GetPtrOrNull ( ) const
inlineconstexpr

◆ GetValue() [1/2]

template<typename OptionalType >
constexpr OptionalType & TOptional< OptionalType >::GetValue ( )
inlineconstexpr
Returns
The optional value; undefined when IsSet() returns false.

◆ GetValue() [2/2]

template<typename OptionalType >
UE_FORCEINLINE_HINT constexpr const OptionalType & TOptional< OptionalType >::GetValue ( ) const
inlineconstexpr

◆ IsSet()

Returns
true when the value is meaningful; false if calling GetValue() is undefined.

◆ operator bool()

template<typename OptionalType >
UE_FORCEINLINE_HINT constexpr TOptional< OptionalType >::operator bool ( ) const
inlineexplicitconstexpr

◆ operator*() [1/2]

template<typename OptionalType >
constexpr OptionalType & TOptional< OptionalType >::operator* ( )
inlineconstexpr

◆ operator*() [2/2]

template<typename OptionalType >
UE_FORCEINLINE_HINT constexpr const OptionalType & TOptional< OptionalType >::operator* ( ) const
inlineconstexpr

◆ operator->() [1/2]

template<typename OptionalType >
constexpr OptionalType * TOptional< OptionalType >::operator-> ( )
inlineconstexpr

◆ operator->() [2/2]

template<typename OptionalType >
UE_FORCEINLINE_HINT constexpr const OptionalType * TOptional< OptionalType >::operator-> ( ) const
inlineconstexpr

◆ operator=() [1/4]

template<typename OptionalType >
TOptional & TOptional< OptionalType >::operator= ( const OptionalType InValue)
inline

◆ operator=() [2/4]

template<typename OptionalType >
TOptional & TOptional< OptionalType >::operator= ( const TOptional< OptionalType > &  Other)
inline

◆ operator=() [3/4]

template<typename OptionalType >
TOptional & TOptional< OptionalType >::operator= ( OptionalType &&  InValue)
inline

◆ operator=() [4/4]

template<typename OptionalType >
TOptional & TOptional< OptionalType >::operator= ( TOptional< OptionalType > &&  Other)
inline

◆ Reset()

template<typename OptionalType >
void TOptional< OptionalType >::Reset ( )
inline

◆ Serialize()

template<typename OptionalType >
void TOptional< OptionalType >::Serialize ( FArchive Ar)
inline

Friends And Related Symbol Documentation

◆ operator!=

template<typename OptionalType >
constexpr bool operator!= ( const TOptional< OptionalType > &  Lhs,
const TOptional< OptionalType > &  Rhs 
)
friend

◆ operator==

template<typename OptionalType >
constexpr bool operator== ( const TOptional< OptionalType > &  Lhs,
const TOptional< OptionalType > &  Rhs 
)
friend

The documentation for this struct was generated from the following files: