UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
IntrinsicClassBaseChain.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#if UE_WITH_CONSTINIT_UOBJECT
6
7#include "UObject/Class.h"
8
9namespace UE::Private
10{
11 template<typename IntrinsicClass>
12 constexpr bool DeferFalse = false;
13
14 template<typename IntrinsicClass>
15 consteval UClass* GetConstInitClass()
16 {
17 static_assert(DeferFalse<IntrinsicClass>, "UE::Private::GetConstInitClass must be specialized for intrinsic classes");
18 return nullptr;
19 }
20
21 template<typename... Classes>
22 struct TIntrinsicClassBaseChainImpl
23 {
24 using BaseChainPtr = const FStructBaseChain*;
25 static constexpr SIZE_T Num = sizeof...(Classes);
26 static inline constinit BaseChainPtr Bases[] = { static_cast<BaseChainPtr>(GetConstInitClass<Classes>())... };
27
28 static consteval TArrayView<const FStructBaseChain*> ToArrayView()
29 {
30 return MakeArrayView(Bases, Num);
31 }
32 };
33
34 template<typename ClassType, typename... Ts>
35 consteval auto DetermineIntrinsicClassBaseChain()
36 {
37 if constexpr (std::is_same_v<ClassType, typename ClassType::Super>)
38 {
39 return TIntrinsicClassBaseChainImpl<ClassType, Ts...>{};
40 }
41 else
42 {
43 return DetermineIntrinsicClassBaseChain<typename ClassType::Super, ClassType, Ts...>();
44 }
45 }
46}
47
48// Template to build a static array of base class pointers for an intrinsic class
49template<typename T>
50using TIntrinsicClassBaseChain = decltype(UE::Private::DetermineIntrinsicClassBaseChain<T>());
51
52#endif // UE_WITH_CONSTINIT_UOBJECT
constexpr auto MakeArrayView(OtherRangeType &&Other)
Definition ArrayView.h:873
FPlatformTypes::SIZE_T SIZE_T
An unsigned integer the same size as a pointer, the same as UPTRINT.
Definition Platform.h:1150
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
@ Num
Definition MetalRHIPrivate.h:234
Definition Class.h:412
Definition ArrayView.h:139
Definition Class.h:3793
Definition PackageReader.cpp:44