Description
Clears the optional back to an unset state, destroying the held value if one is present. After this call IsSet() returns false.
Caveats & Gotchas
- • Calling Reset() on an already-unset TOptional is safe and a no-op — no destructor is invoked.
- • For intrusive optional types (those that implement FIntrusiveUnsetOptionalState), Reset() reconstructs the unset sentinel value in-place rather than simply clearing a boolean flag. The object's destructor is still called first.
Signature
void Reset() Return Type
void Example
Clearing a cached optional value C++
TOptional<FHitResult> CachedHit = PerformTrace();
// Invalidate the cache on component deactivation:
void UMyComponent::Deactivate()
{
CachedHit.Reset();
check(!CachedHit.IsSet());
} See Also
Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?