UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VVMGlobalHeapPtr.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#if WITH_VERSE_VM || defined(__INTELLISENSE__)
6
8#include "VVMGlobalHeapRoot.h"
10#include "VVMMarkStack.h"
11#include "VVMMarkStackVisitor.h"
12#include "VVMWriteBarrier.h"
13
14namespace Verse
15{
16
17template <typename T>
19 , TWriteBarrier<T>
20{
21 TGlobalHeapPtrImpl() = default;
22
23 TGlobalHeapPtrImpl(FAccessContext Context, typename TWriteBarrier<T>::TValue Value)
26 {
27 }
28
29 void Visit(FMarkStackVisitor& Visitor) override { VisitImpl(Visitor); }
30 void Visit(FAbstractVisitor& Visitor) override { VisitImpl(Visitor); }
31
32 template <class VisitorType>
33 void VisitImpl(VisitorType& Visitor)
34 {
36 Visitor.Visit(GlobalHeapPtr, TEXT("GlobalHeapPtr"));
37 }
38};
39
40template <typename T>
41struct TGlobalHeapPtr
42{
43 static constexpr bool bIsVValue = std::is_same_v<T, VValue>;
44 using TValue = typename std::conditional<bIsVValue, VValue, T*>::type;
45
46 TGlobalHeapPtr() = default;
47
48 TGlobalHeapPtr(const TGlobalHeapPtr&) = delete;
49 TGlobalHeapPtr& operator=(const TGlobalHeapPtr&) = delete;
51 TGlobalHeapPtr& operator=(TGlobalHeapPtr&&) = delete;
52
53 void Set(FAccessContext Context, TValue NewValue)
54 {
55 Impl->Set(Context, NewValue);
56 }
57
58 template <typename TResult = void>
59 std::enable_if_t<bIsVValue, TResult> SetNonCellNorPlaceholder(VValue NewValue)
60 {
61 Impl->SetNonCellNorPlaceholder(NewValue);
62 }
63
64 TValue Get() const { return Impl->Get(); }
65
66 // nb: operators "*" and "->" disabled for TGlobalHeapPtr<VValue>;
67 // use Get() + VValue member functions to check/access boxed values
68
69 template <typename TResult = TValue>
70 std::enable_if_t<!bIsVValue, TResult> operator->() const { return Impl->Get(); }
71
72 template <typename TResult = T>
73 std::enable_if_t<!bIsVValue, TResult&> operator*() const { return *Impl->Get(); }
74
75 explicit operator bool() const { return !!Impl->Get(); }
76
77private:
79};
80
81} // namespace Verse
82#endif // WITH_VERSE_VM
UE_FORCEINLINE_HINT FLinearColor operator*(float Scalar, const FLinearColor &Color)
Definition Color.h:473
#define TEXT(x)
Definition Platform.h:1272
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
const bool
Definition NetworkReplayStreaming.h:178
decltype(auto) Visit(Func &&Callable, Variants &&... Args)
Definition TVariant.h:271
@ Visitor
Definition XmppMultiUserChat.h:94
Definition ExpressionParserTypes.h:21
FORCEINLINE T * Get(const FObjectPtr &ObjectPtr)
Definition ObjectPtr.h:426
decltype(auto) VisitImpl(SIZE_T EncodedIndex, Func &&Callable, TIntegerSequence< SIZE_T, EncodedIndices... > &&, TIntegerSequence< SIZE_T, VariantIndices... > &&VariantIndicesSeq, Variants &&... Args)
Definition TVariantMeta.h:377
Definition Archive.h:36