UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TOptionalGuardValue< RefType, AssignedType > Struct Template Reference

#include <UnrealTemplate.h>

+ Inheritance diagram for TOptionalGuardValue< RefType, AssignedType >:

Public Member Functions

 TOptionalGuardValue (RefType &ReferenceValue, const AssignedType &NewValue)
 
 ~TOptionalGuardValue ()
 
UE_FORCEINLINE_HINT const AssignedTypeGetOriginalValue () const
 

Detailed Description

template<typename RefType, typename AssignedType = RefType>
struct TOptionalGuardValue< RefType, AssignedType >

exception-safe guard around saving/restoring a value. Commonly used to make sure a value is restored even if the code early outs in the future. Usage: TOptionalGuardValue<bool> GuardSomeBool(bSomeBool, false); // Sets bSomeBool to false, and restores it in dtor.

Constructor & Destructor Documentation

◆ TOptionalGuardValue()

template<typename RefType , typename AssignedType = RefType>
TOptionalGuardValue< RefType, AssignedType >::TOptionalGuardValue ( RefType &  ReferenceValue,
const AssignedType NewValue 
)
inline

◆ ~TOptionalGuardValue()

template<typename RefType , typename AssignedType = RefType>
TOptionalGuardValue< RefType, AssignedType >::~TOptionalGuardValue ( )
inline

Member Function Documentation

◆ GetOriginalValue()

template<typename RefType , typename AssignedType = RefType>
UE_FORCEINLINE_HINT const AssignedType & TOptionalGuardValue< RefType, AssignedType >::GetOriginalValue ( ) const
inline

Provides read-only access to the original value of the data being tracked by this struct

Returns
a const reference to the original data value

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