UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ParameterizedTypes.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6
7namespace UE
8{
9namespace Geometry
10{
11namespace Spline
12{
13
17template<typename T, int32 D>
19{
20 // Default case - invalid
21 using Type = void;
22};
23
24// Specializations for 2D vectors
25template<> struct TVectorPolicy<float, 2> { using Type = FVector2f; };
26template<> struct TVectorPolicy<double, 2> { using Type = FVector2D; };
27template<> struct TVectorPolicy<int32, 2> { using Type = FIntPoint; };
28
29// Specializations for 3D vectors
30template<> struct TVectorPolicy<float, 3> { using Type = FVector3f; };
31template<> struct TVectorPolicy<double, 3> { using Type = FVector; };
32template<> struct TVectorPolicy<int32, 3> { using Type = FIntVector; };
33
34// Specializations for 4D vectors
35template<> struct TVectorPolicy<float, 4> { using Type = FVector4f; };
36template<> struct TVectorPolicy<double, 4> { using Type = FVector4d; };
37template<> struct TVectorPolicy<int32, 4> { using Type = FIntVector4; };
38
42template<typename T>
44{
45 static constexpr bool Value =
46 std::is_same<T, float>::value ||
47 std::is_same<T, double>::value ||
48 std::is_same<T, int32>::value;
49};
50
51template<typename T, int32 D>
53{
54 static_assert(TIsValidVectorType<T>::Value,
55 "Vector component type must be float, double, or int32");
56 static_assert(D >= 2 && D <= 4,
57 "Vector dimension must be 2, 3, or 4");
58
60 static_assert(!std::is_same<Type, void>::value,
61 "Invalid vector type combination");
62};
63
64// Trait to detect if a type T has an Equals(const T&) method.
65template<typename T, typename = void>
66struct THasEqualsMethod : std::false_type {};
67
68template<typename T>
69struct THasEqualsMethod<T, std::void_t<decltype(std::declval<T>().Equals(std::declval<T>()))>>
70 : std::true_type {};
71
72// Trait to detect if type T has a static EqualTo(const T&, const T&) method.
73template<typename T, typename = void>
74struct THasEqualToMethod : std::false_type {};
75
76template<typename T>
77struct THasEqualToMethod<T, std::void_t<decltype(T::EqualTo(std::declval<T>(), std::declval<T>()))>>
78 : std::true_type {};
79
81template<typename T, typename = void>
82struct THasSerializeMethod : std::false_type {};
83
84template<typename T>
86 std::void_t<decltype(std::declval<T>().Serialize(std::declval<FArchive&>()))>
87> : std::true_type {};
88
90template<typename T, typename = void>
91struct THasArchiveOperator : std::false_type {};
92
93template<typename T>
95 std::void_t<decltype(std::declval<FArchive&>() << std::declval<T&>())>
96> : std::true_type {};
97
103// Detector for Size() method
104template<typename T, typename = void>
105struct THasSizeMethod : std::false_type {};
106
107template<typename T>
108struct THasSizeMethod<T, std::void_t<decltype(std::declval<T>().Size())>>
109 : std::true_type {};
110
111// Detector for SizeSquared() method
112template<typename T, typename = void>
113struct THasSizeSquaredMethod : std::false_type {};
114
115template<typename T>
116struct THasSizeSquaredMethod<T, std::void_t<decltype(std::declval<T>().SizeSquared())>>
117 : std::true_type {};
118
119// Detector for Dot() method
120template<typename T, typename = void>
121struct THasDotMethod : std::false_type {};
122
123template<typename T>
124struct THasDotMethod<T, std::void_t<decltype(std::declval<T>().Dot(std::declval<T>()))>>
125 : std::true_type {};
126
127// Detector for GetSafeNormal() method
128template<typename T, typename = void>
129struct THasGetSafeNormalMethod : std::false_type {};
130
131template<typename T>
132struct THasGetSafeNormalMethod<T, std::void_t<decltype(std::declval<T>().GetSafeNormal())>>
133 : std::true_type {};
134
135// Detector for operator- (subtraction)
136template<typename T, typename = void>
137struct THasSubtractionOperator : std::false_type {};
138
139template<typename T>
140struct THasSubtractionOperator<T, std::void_t<decltype(std::declval<T>() - std::declval<T>())>>
141 : std::true_type {};
142
143// Detector for operator+ (addition)
144template<typename T, typename = void>
145struct THasAdditionOperator : std::false_type {};
146
147template<typename T>
148struct THasAdditionOperator<T, std::void_t<decltype(std::declval<T>() + std::declval<T>())>>
149 : std::true_type {};
150
151// Detector for operator* (scalar multiplication)
152template<typename T, typename = void>
153struct THasScalarMultiplicationOperator : std::false_type {};
154
155template<typename T>
156struct THasScalarMultiplicationOperator<T, std::void_t<decltype(std::declval<T>() * std::declval<float>())>>
157 : std::true_type {};
158
159// Detector for ZeroVector static member (for proper Zero value)
160template<typename T, typename = void>
161struct THasZeroVectorMember : std::false_type {};
162
163template<typename T>
164struct THasZeroVectorMember<T, std::void_t<decltype(T::ZeroVector)>>
165 : std::true_type {};
166
167
168} // end namespace UE::Geometry::Spline
169} // end namespace UE::Geometry
170} // end namespace UE
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define FVector
Definition IOSSystemIncludes.h:8
UE::Math::TVector2< float > FVector2f
Definition MathFwd.h:74
UE::Math::TVector4< double > FVector4d
Definition MathFwd.h:62
UE::Math::TVector< float > FVector3f
Definition MathFwd.h:73
UE::Math::TVector2< double > FVector2D
Definition MathFwd.h:48
UE::Math::TIntVector4< int32 > FIntVector4
Definition MathFwd.h:93
FInt32Vector3 FIntVector
Definition MathFwd.h:115
UE::Math::TVector4< float > FVector4f
Definition MathFwd.h:75
FInt32Point FIntPoint
Definition MathFwd.h:124
USkinnedMeshComponent float
Definition SkinnedMeshComponent.h:60
Definition AdvancedWidgetsModule.cpp:13
Definition ParameterizedTypes.h:53
typename TVectorPolicy< T, D >::Type Type
Definition ParameterizedTypes.h:59
Definition ParameterizedTypes.h:91
Definition ParameterizedTypes.h:74
Definition ParameterizedTypes.h:66
Definition ParameterizedTypes.h:82
Definition ParameterizedTypes.h:44
static constexpr bool Value
Definition ParameterizedTypes.h:45
Definition ParameterizedTypes.h:19
void Type
Definition ParameterizedTypes.h:21
Definition IntPoint.h:25