UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
RetainedRef.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
60template <typename T>
62{
64 : Ref(InRef)
65 {
66 }
67
68 // Can't construct a non-const reference with a const reference
69 // and can't retain a rvalue reference.
70 TRetainedRef(const T& InRef) = delete;
71 TRetainedRef( T&& InRef) = delete;
72 TRetainedRef(const T&& InRef) = delete;
73
74 operator T&() const
75 {
76 return Ref;
77 }
78
79 T& Get() const
80 {
81 return Ref;
82 }
83
84private:
85 T& Ref;
86};
87
88template <typename T>
89struct TRetainedRef<const T>
90{
92 : Ref(InRef)
93 {
94 }
95
97 : Ref(InRef)
98 {
99 }
100
101 // Can't retain a rvalue reference.
102 TRetainedRef( T&& InRef) = delete;
103 TRetainedRef(const T&& InRef) = delete;
104
105 operator const T&() const
106 {
107 return Ref;
108 }
109
110 const T& Get() const
111 {
112 return Ref;
113 }
114
115private:
116 const T& Ref;
117};
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
TRetainedRef(T &&InRef)=delete
const T & Get() const
Definition RetainedRef.h:110
TRetainedRef(const T &InRef)
Definition RetainedRef.h:96
TRetainedRef(const T &&InRef)=delete
TRetainedRef(T &InRef)
Definition RetainedRef.h:91
Definition RetainedRef.h:62
TRetainedRef(T &&InRef)=delete
TRetainedRef(const T &&InRef)=delete
TRetainedRef(const T &InRef)=delete
T & Get() const
Definition RetainedRef.h:79
TRetainedRef(T &InRef)
Definition RetainedRef.h:63