UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Projection.h File Reference
#include "AutoRTFM.h"
#include <type_traits>

Go to the source code of this file.

Classes

struct  UE::Core::Private::TProjectionMemberFunction< FunctionType ClassType::* >
 
struct  UE::Core::Private::TProjectionMemberData< MemberType ClassType::* >
 

Namespaces

namespace  UE
 
namespace  UE::Core
 
namespace  UE::Core::Private
 implementation
 

Functions

template<typename Class , typename MemberType >
constexpr bool UE::Core::Private::TIsMemberPointerToFunction (MemberType Class::*)
 
template<typename Invocable0Type , typename... InvocableTypes>
AUTORTFM_INFER constexpr auto Projection (Invocable0Type &&Invocable0, InvocableTypes &&... Invocables)
 

Variables

template<typename InvocableType >
struct AUTORTFM_INFER UE::Core::Private::TProjectionMemberFunction
 

Function Documentation

◆ Projection()

template<typename Invocable0Type , typename... InvocableTypes>
AUTORTFM_INFER constexpr auto Projection ( Invocable0Type &&  Invocable0,
InvocableTypes &&...  Invocables 
)
constexpr

Projection() is a related function to Invoke(), in that it can be used to invoke an object with a set of arguments. However, it works by transforming something invocable into something callable, i.e. can be called with a normal parenthesized set of arguments.

// These are equivalent: Projection(I)(Args...) Invoke(I, Args...).

... with the same advantages:

// Can accept member function pointers Invoke(&FObjType::Member, Obj); // equivalent to Obj.Member Invoke(&FObjType::Func, Obj, Args...); // equivalent to Obj.Func(Args...) Projection(&FObjType::Member)(Obj); // equivalent to Obj.Member Projection(&FObjType::Func)(Obj, Args...); // equivalent to Obj.Func(Args...)

// Can operate on pointers, including smart pointers Invoke(&FObjType::Member, ObjPtr); // equivalent to ObjPtr->Member Invoke(&FObjType::Func, ObjPtr, Args...); // equivalent to ObjPtr->Func(Args...) Projection(&FObjType::Member)(ObjPtr); // equivalent to ObjPtr->Member Projection(&FObjType::Func)(ObjPtr, Args...); // equivalent to ObjPtr->Func(Args...)

However, Projection() has some additional advantages:

  • Projection(I) returns I unchanged if it is already callable, meaning no redundant stepping in and out of many Invoke() calls in the debugger.
  • Projection(...) is variadic and can transform a sequence of invocables into a callable that invokes them one by one:

Projection(A, B, C)(Args...) Invoke(C, Invoke(B, Invoke(A, Args...)))

This allows users to pass a sequence of projections to an algorithm that takes a single projection:

struct FInner { FString Name; }; struct FOuter { FInner Inner; };

// Sort array of outers by the names of inner, Algo::SortBy(ArrayOfOuters, Projection(&FOuter::Inner, &FInner::Name));