TOptional

When we have an optional value [IsSet()](API\Runtime\Core\Misc\TOptional\IsSet) returns true, and [GetValue()](API\Runtime\Core\Misc\TOptional\GetValue\2) is meaningful.

Windows
MacOS
Linux

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/Misc/Optional.h

Include

#include "Misc/Optional.h"

Syntax

template<typename OptionalType>
struct TOptional

Remarks

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

Constructors

Name Description

Public function

TOptional()

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

Public function

TOptional

(
    const OptionalType& InValue
)

Construct an OptionaType with a valid value.

Public function

TOptional

(
    OptionalType&& InValue
)

Public function

TOptional

(
    const TOptional& InValue
)

Copy/Move construction

Public function

TOptional

(
    TOptional&& InValue
)

Destructors

Name Description

Public function

~TOptional()

Functions

Name Description

Public function

void

 

Emplace

(
    ArgsType&&... Args
)

Public function Const

const Option...

 

Get

(
    const OptionalType& DefaultValue
)

Public function Const

const Option...

 

GetValue()

Public function

OptionalType...

 

GetValue()

Public function Const

bool

 

IsSet()

Public function

void

 

Reset()

Operators

Name Description

Public function Const

 

operator bool()

Public function

TOptional &

 

operator=

(
    OptionalType&& InValue
)

Public function

TOptional &

 

operator=

(
    const OptionalType& InValue
)

Public function

TOptional &

 

operator=

(
    TOptional&& InValue
)

Public function

TOptional &

 

operator=

(
    const TOptional& InValue
)

Public function Const

const Option...

 

operator->()

Public function

OptionalType...

 

operator->()

Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback