UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AlignedElement.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"
6#include <type_traits>
7
8namespace UE::Core
9{
10 // Helper class to wrap a type for alignment in containers
11 template <typename T, uint32 Alignment>
13 {
14 static_assert(!std::is_reference_v<T>);
15
17
19 {
21 return *this;
22 }
23
25 {
26 Value = Other;
27 return *this;
28 }
29
30 UE_REWRITE constexpr operator T&&()&&
31 {
32 return MoveTemp(Value);
33 }
34
35 UE_REWRITE constexpr operator const T&() const&
36 {
37 return Value;
38 }
39
40 UE_REWRITE constexpr operator T&()&
41 {
42 return Value;
43 }
44 };
45
46 template <typename T, uint32 Alignment> requires(std::is_class_v<T> && !std::is_final_v<T>)
47 struct alignas(Alignment) TAlignedElement<T, Alignment>: T
48 {
50 {
51 T::operator=(MoveTemp(Other));
52 return *this;
53 }
54
56 {
57 T::operator=(Other);
58 return *this;
59 }
60 };
61}
#define UE_REWRITE
Definition Platform.h:747
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
Definition PlayInEditorLoadingScope.h:8
UE_REWRITE constexpr TAlignedElement & operator=(const T &Other)
Definition AlignedElement.h:55
UE_REWRITE constexpr TAlignedElement & operator=(T &&Other)
Definition AlignedElement.h:49
Definition AlignedElement.h:13
T Value
Definition AlignedElement.h:16
UE_REWRITE constexpr TAlignedElement & operator=(const T &Other)
Definition AlignedElement.h:24
UE_REWRITE constexpr TAlignedElement & operator=(T &&Other)
Definition AlignedElement.h:18