RealDocs

TOptional::TypedValue

property Core Since unknown
#include "Misc/Optional.h"
Access: private

Description

The raw in-place storage for the optional's value, declared inside an anonymous union so that construction and destruction are fully manual. Do not access this directly — use GetValue() or Get().

Caveats & Gotchas

  • TypedValue is private and must never be accessed directly from outside TOptional. Its lifetime is managed manually via placement-new and explicit destructor calls; reading it when IsSet() is false is undefined behaviour.
  • On compilers that support constrained destructors (PLATFORM_COMPILER_SUPPORTS_CONSTRAINED_DESTRUCTORS), TypedValue is a direct member of TOptional. On older compilers it lives in the TOptionalBase base class and is inherited — the layout is the same but the declaration site differs.

Signature

OptionalType TypedValue

Example

Correct access pattern using the public API C++
TOptional<FVector> MaybePos = GetActorOptionalPos();
if (MaybePos.IsSet())
{
    FVector Pos = MaybePos.GetValue(); // correct — uses public accessor
    // Do NOT write: MaybePos.TypedValue (private)
}

Version History

Introduced in: unknown

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.