UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Projection.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "AutoRTFM.h"
6#include <type_traits>
7
8namespace UE::Core::Private
9{
10 template <typename InvocableType>
12
13 template <typename ClassType, typename FunctionType>
14 struct AUTORTFM_INFER TProjectionMemberFunction<FunctionType ClassType::*>
15 {
16 FunctionType ClassType::* MemberFunctionPtr;
17
18 template <typename Arg0Type, typename... ArgTypes>
19 constexpr decltype(auto) operator()(Arg0Type&& Arg0, ArgTypes&&... Args) const
20 {
21 using DecayedArg0Type = std::decay_t<Arg0Type>;
22 if constexpr (std::is_base_of_v<ClassType, DecayedArg0Type>)
23 {
24 return (((Arg0Type&&)Arg0).*this->MemberFunctionPtr)((ArgTypes&&)Args...);
25 }
26 else
27 {
28 return ((*(Arg0Type&&)Arg0).*this->MemberFunctionPtr)((ArgTypes&&)Args...);
29 }
30 }
31 };
32
33 template <typename InvocableType>
35
36 template <typename ClassType, typename MemberType>
37 struct TProjectionMemberData<MemberType ClassType::*>
38 {
39 MemberType ClassType::* DataMemberPtr;
40
41 template <typename Arg0Type>
42 constexpr decltype(auto) operator()(Arg0Type&& Arg0) const
43 {
44 using DecayedArg0Type = std::decay_t<Arg0Type>;
45 if constexpr (std::is_base_of_v<ClassType, DecayedArg0Type>)
46 {
47 return ((Arg0Type&&)Arg0).*this->DataMemberPtr;
48 }
49 else
50 {
51 return (*(Arg0Type&&)Arg0).*this->DataMemberPtr;
52 }
53 }
54 };
55
56 template <typename Class, typename MemberType>
57 inline constexpr bool TIsMemberPointerToFunction(MemberType Class::*)
58 {
59 return std::is_function_v<MemberType>;
60 }
61}
62
107template <typename Invocable0Type, typename... InvocableTypes>
108AUTORTFM_INFER [[nodiscard]] constexpr auto Projection(Invocable0Type&& Invocable0, InvocableTypes&&... Invocables)
109{
110 if constexpr (sizeof...(InvocableTypes) == 0)
111 {
112 using DecayedInvocable0Type = std::decay_t<Invocable0Type>;
113 if constexpr (!std::is_member_pointer_v<DecayedInvocable0Type>)
114 {
115 return (Invocable0Type&&)Invocable0;
116 }
118 {
119 return UE::Core::Private::TProjectionMemberFunction<DecayedInvocable0Type>{ (Invocable0Type&&)Invocable0 };
120 }
121 else
122 {
124 }
125 }
126 else
127 {
128 return [Callable0 = Projection((Invocable0Type&&)Invocable0), CallableRest = Projection((InvocableTypes&&)Invocables...)](auto&&... Args) -> decltype(auto)
129 {
130 return CallableRest(Callable0((decltype(Args)&&)Args...));
131 };
132 }
133}
#define AUTORTFM_INFER
Definition AutoRTFMDefines.h:121
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
AUTORTFM_INFER constexpr auto Projection(Invocable0Type &&Invocable0, InvocableTypes &&... Invocables)
Definition Projection.h:108
implementation
Definition PlayInEditorLoadingScope.h:8
constexpr bool TIsMemberPointerToFunction(MemberType Class::*)
Definition Projection.h:57
struct AUTORTFM_INFER TProjectionMemberFunction
Definition Projection.h:11
MemberType ClassType::* DataMemberPtr
Definition Projection.h:39
FunctionType ClassType::* MemberFunctionPtr
Definition Projection.h:16