UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MemoryOps.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include <string.h>
7
8namespace uLang
9{
10
11namespace Private
12{
13 template <typename DestinationElementType, typename SourceElementType>
28}
29
36template <typename ElementType>
38{
39 ElementType* Element = (ElementType*)Address;
40 while (Count > 0)
41 {
42 new (Element) ElementType;
43 ++Element;
44 --Count;
45 }
46}
47
48
49template <typename ElementType>
51{
52 if (Count)
53 {
54 memset(Elements, 0, sizeof(ElementType) * Count);
55 }
56}
57
58
66template <typename ElementType>
68{
69 // We need a typedef here because VC won't compile the destructor call below if ElementType itself has a member called ElementType
70 using DestructItemsElementTypeTypedef = ElementType;
71
72 Element->DestructItemsElementTypeTypedef::~DestructItemsElementTypeTypedef();
73}
74
75
76template <typename ElementType>
80
81
90template <typename ElementType>
92{
93 while (Count > 0)
94 {
95 // We need a typedef here because VC won't compile the destructor call below if ElementType itself has a member called ElementType
96 using DestructItemsElementTypeTypedef = ElementType;
97
98 Element->DestructItemsElementTypeTypedef::~DestructItemsElementTypeTypedef();
99 ++Element;
100 --Count;
101 }
102}
103
104
105template <typename ElementType>
109
110
118template <typename DestinationElementType, typename SourceElementType>
129
130
131template <typename DestinationElementType, typename SourceElementType>
139
140
149template <typename DestinationElementType, typename SourceElementType>
151{
152 while (Count > 0)
153 {
154 // We need a typedef here because VC won't compile the destructor call below if SourceElementType itself has a member called SourceElementType
156
157 new (Dest) DestinationElementType(*Source);
158 ++(DestinationElementType*&)Dest;
160 --Count;
161 }
162}
163
164template <typename DestinationElementType, typename SourceElementType>
166{
167 /* All existing UE containers seem to assume trivial relocatability (i.e. memcpy'able) of their members,
168 * so we're going to assume that this is safe here. However, it's not generally possible to assume this
169 * in general as objects which contain pointers/references to themselves are not safe to be trivially
170 * relocated.
171 *
172 * However, it is not yet possible to automatically infer this at compile time, so we can't enable
173 * different (i.e. safer) implementations anyway. */
174 if (Count)
175 {
176 memmove(Dest, Source, sizeof(SourceElementType) * Count);
177 }
178}
179
180
181template <typename ElementType>
183{
184 if (Count)
185 {
186 return !memcmp(A, B, sizeof(ElementType) * Count);
187 }
188
189 return true;
190}
191
192
193template <typename ElementType>
195{
196 while (Count > 0)
197 {
198 if (!(*A == *B))
199 {
200 return false;
201 }
202
203 ++A;
204 ++B;
205 --Count;
206 }
207
208 return true;
209}
210
211}
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define ULANG_FORCEINLINE
Definition Common.h:188
memcpy(InputBufferBase, BinkBlocksData, BinkBlocksSize)
Definition Conditionals.h:95
Definition OverriddenPropertySet.cpp:45
Definition VVMEngineEnvironment.h:23
ULANG_FORCEINLINE TEnableIf<!TIsTriviallyDestructible< ElementType >::Value >::Type DestructElement(ElementType *Element)
Definition MemoryOps.h:67
ULANG_FORCEINLINE TEnableIf<!TIsZeroConstructType< ElementType >::Value >::Type DefaultConstructElements(void *Address, int32_t Count)
Definition MemoryOps.h:37
ULANG_FORCEINLINE TEnableIf<!TIsBitwiseConstructible< DestinationElementType, SourceElementType >::Value >::Type ConstructElements(void *Dest, const SourceElementType *Source, int32_t Count)
Definition MemoryOps.h:119
ULANG_FORCEINLINE TEnableIf< TTypeTraits< ElementType >::IsBytewiseComparable, bool >::Type CompareElements(const ElementType *A, const ElementType *B, int32_t Count)
Definition MemoryOps.h:182
ULANG_FORCEINLINE TEnableIf<!TIsTriviallyDestructible< ElementType >::Value >::Type DestructElements(ElementType *Element, int32_t Count)
Definition MemoryOps.h:91
ULANG_FORCEINLINE TEnableIf<!Private::TCanBitwiseRelocate< DestinationElementType, SourceElementType >::Value >::Type RelocateConstructElements(void *Dest, const SourceElementType *Source, int32_t Count)
Definition MemoryOps.h:150
Definition MemoryOps.h:15
@ Value
Definition MemoryOps.h:18
Definition Conditionals.h:16
Definition TypeTraits.h:36
Definition TypeTraits.h:473
Definition TypeTraits.h:249
Definition Conditionals.h:45