UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
NoDestroy.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
7
8// Special tag for TNoDestroy consteval constructor to avoid confusion with the inner type having
9// its own tagged consteval constructor
11
16template<typename T>
18{
19 using ElementType = T;
20
21 template<typename... ArgTypes>
22 [[nodiscard]] explicit consteval TNoDestroy(ENoDestroyConstEval, ArgTypes&&... InArgs)
23 : Value(Forward<ArgTypes>(InArgs)...)
24 {
25 }
26
27 template<typename... ArgTypes>
28 [[nodiscard]] explicit constexpr TNoDestroy(ArgTypes&&... InArgs)
29 : Value(Forward<ArgTypes>(InArgs)...)
30 {
31 }
32
34
35 constexpr ~TNoDestroy()
36 {
37 }
38
40 {
41 return &Value;
42 }
43
44 constexpr const ElementType* operator&() const
45 {
46 return &Value;
47 }
48
50 {
51 return Value;
52 }
53
54 constexpr const ElementType& operator*() const
55 {
56 return Value;
57 }
58
60 {
61 return &Value;
62 }
63
64 const ElementType* operator->() const
65 {
66 return &Value;
67 }
68private:
69 ElementType Value;
70};
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
ENoDestroyConstEval
Definition NoDestroy.h:10
@ NoDestroyConstEval
Definition NoDestroy.h:10
Definition NoDestroy.h:18
ElementType * operator->()
Definition NoDestroy.h:59
UE_NONCOPYABLE(TNoDestroy)
constexpr ElementType * operator&()
Definition NoDestroy.h:39
consteval TNoDestroy(ENoDestroyConstEval, ArgTypes &&... InArgs)
Definition NoDestroy.h:22
constexpr ~TNoDestroy()
Definition NoDestroy.h:35
T ElementType
Definition NoDestroy.h:19
constexpr const ElementType & operator*() const
Definition NoDestroy.h:54
constexpr TNoDestroy(ArgTypes &&... InArgs)
Definition NoDestroy.h:28
constexpr const ElementType * operator&() const
Definition NoDestroy.h:44
constexpr ElementType & operator*()
Definition NoDestroy.h:49
const ElementType * operator->() const
Definition NoDestroy.h:64