Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
Invoke.h File Reference
#include "CoreTypes.h"
#include "Traits/MemberFunctionPtrOuter.h"
#include "Templates/UnrealTemplate.h"
#include <type_traits>
+ Include dependency graph for Invoke.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  UE::Core::Private::TInvokeResult_Impl< typename, FuncType, ArgTypes >
 
struct  UE::Core::Private::TInvokeResult_Impl< decltype((void) Invoke(DeclVal< FuncType >(), DeclVal< ArgTypes >()...)), FuncType, ArgTypes... >
 
struct  TInvokeResult< FuncType, ArgTypes >
 

Namespaces

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

Macros

#define UE_PROJECTION(FuncName)
 
#define UE_PROJECTION_MEMBER(Type, FuncName)
 

Typedefs

template<typename FuncType , typename... ArgTypes>
using TInvokeResult_T = typename TInvokeResult<FuncType, ArgTypes...>::Type
 

Functions

template<typename OuterType , typename TargetType >
FORCEINLINE auto UE::Core::Private::DereferenceIfNecessary (TargetType &&Target, const volatile OuterType *TargetPtr) -> decltype((TargetType &&) Target)
 
template<typename OuterType , typename TargetType >
FORCEINLINE auto UE::Core::Private::DereferenceIfNecessary (TargetType &&Target,...) -> decltype(*(TargetType &&) Target)
 
template<typename FuncType , typename... ArgTypes>
FORCEINLINE auto Invoke (FuncType &&Func, ArgTypes &&... Args) -> decltype(Forward< FuncType >(Func)(Forward< ArgTypes >(Args)...))
 
template<typename ReturnType , typename ObjType , typename TargetType >
FORCEINLINE auto Invoke (ReturnType ObjType::*pdm, TargetType &&Target) -> decltype(UE::Core::Private::DereferenceIfNecessary< ObjType >(Forward< TargetType >(Target), &Target).*pdm)
 
template<typename PtrMemFunType , typename TargetType , typename... ArgTypes, typename ObjType = TMemberFunctionPtrOuter_T<PtrMemFunType>>
FORCEINLINE auto Invoke (PtrMemFunType PtrMemFun, TargetType &&Target, ArgTypes &&... Args) -> decltype((UE::Core::Private::DereferenceIfNecessary< ObjType >(Forward< TargetType >(Target), &Target).*PtrMemFun)(Forward< ArgTypes >(Args)...))
 

Macro Definition Documentation

◆ UE_PROJECTION

#define UE_PROJECTION ( FuncName)
Value:
[](auto&&... Args) -> decltype(auto) \
{ \
return FuncName(Forward<decltype(Args)>(Args)...); \
}

Wraps up a named non-member function so that it can easily be passed as a callable. This allows functions with overloads or default arguments to be treated correctly.

Example:

TArray<FMyType> Array = ...;

// Doesn't compile, because you can't take the address of an overloaded function when its type needs to be deduced. Algo::SortBy(Array, &LexToString);

// Works as expected Algo::SortBy(Array, UE_PROJECTION(LexToString));

Definition at line 84 of file Invoke.h.

◆ UE_PROJECTION_MEMBER

#define UE_PROJECTION_MEMBER ( Type,
FuncName )
Value:
[](auto&& Obj, auto&&... Args) -> decltype(auto) \
{ \
return UE::Core::Private::DereferenceIfNecessary<Type>(Forward<decltype(Obj)>(Obj), &Obj).FuncName(Forward<decltype(Args)>(Args)...); \
}

Wraps up a named member function so that it can easily be passed as a callable. This allows functions with overloads or default arguments to be treated correctly.

Example:

TArray<UObject*> Array = ...;

// Doesn't compile, because &UObject::GetFullName loses the default argument and passes // FString (UObject::*)(const UObject*) to Algo::SortBy<>(), which is not a valid projection. Algo::SortBy(Array, &UObject::GetFullName);

// Works as expected Algo::SortBy(Array, UE_PROJECTION_MEMBER(UObject, GetFullName));

Definition at line 105 of file Invoke.h.

Typedef Documentation

◆ TInvokeResult_T

template<typename FuncType , typename... ArgTypes>
using TInvokeResult_T = typename TInvokeResult<FuncType, ArgTypes...>::Type

Definition at line 135 of file Invoke.h.

Function Documentation

◆ Invoke() [1/3]

template<typename FuncType , typename... ArgTypes>
FORCEINLINE auto Invoke ( FuncType && Func,
ArgTypes &&... Args ) -> decltype(Forward<FuncType>(Func)(Forward<ArgTypes>(Args)...))

Invokes a callable with a set of arguments. Allows the following:

  • Calling a functor object given a set of arguments.
  • Calling a function pointer given a set of arguments.
  • Calling a member function given a reference to an object and a set of arguments.
  • Calling a member function given a pointer (including smart pointers) to an object and a set of arguments.
  • Projecting via a data member pointer given a reference to an object.
  • Projecting via a data member pointer given a pointer (including smart pointers) to an object.

See: http://en.cppreference.com/w/cpp/utility/functional/invoke

Definition at line 44 of file Invoke.h.

◆ Invoke() [2/3]

template<typename PtrMemFunType , typename TargetType , typename... ArgTypes, typename ObjType = TMemberFunctionPtrOuter_T<PtrMemFunType>>
FORCEINLINE auto Invoke ( PtrMemFunType PtrMemFun,
TargetType && Target,
ArgTypes &&... Args ) -> decltype((UE::Core::Private::DereferenceIfNecessary<ObjType>(Forward<TargetType>(Target), &Target).*PtrMemFun)(Forward<ArgTypes>(Args)...))

Definition at line 63 of file Invoke.h.

◆ Invoke() [3/3]

template<typename ReturnType , typename ObjType , typename TargetType >
FORCEINLINE auto Invoke ( ReturnType ObjType::* pdm,
TargetType && Target ) -> decltype(UE::Core::Private::DereferenceIfNecessary<ObjType>(Forward<TargetType>(Target), &Target).*pdm)

Definition at line 51 of file Invoke.h.