UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Overload.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
55#include <type_traits>
56
58
59namespace UE::Core::Private
60{
61 template <typename... InvocableTypes>
62 struct TOverload : InvocableTypes...
63 {
64 using InvocableTypes::operator()...;
65 };
66
67 template <typename RetType, typename... ArgTypes>
69 {
70 RetType (*Callable)(ArgTypes...);
71
72 UE_REWRITE constexpr RetType operator()(ArgTypes... Args) const
73 {
74 return Callable((ArgTypes&&)Args...);
75 }
76 };
77
78 // This wraps function pointers in an object so they can be inherited by TOverload
79 template <typename RetType, typename... ArgTypes>
80 [[nodiscard]] UE_REWRITE constexpr TOverloadWrapper<RetType, ArgTypes...> MakeCallableObject(RetType(*Callable)(ArgTypes...))
81 {
82 return { Callable };
83 }
84
85 template <typename CallableType>
86 requires (!std::is_pointer_v<std::decay_t<CallableType>>)
88 {
89 return (CallableType&&)Callable;
90 }
91}
92
93namespace UE
94{
95 // Combines a set of invocable objects into one and overloads them.
96 template <typename... InvocableTypes>
97 [[nodiscard]] UE_REWRITE constexpr auto Overload(InvocableTypes&&... Invocables)
98 {
100 }
101}
#define UE_REWRITE
Definition Platform.h:747
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
UE_REWRITE constexpr TOverloadWrapper< RetType, ArgTypes... > MakeCallableObject(RetType(*Callable)(ArgTypes...))
Definition Overload.h:80
Definition AdvancedWidgetsModule.cpp:13
UE_REWRITE constexpr auto Overload(InvocableTypes &&... Invocables)
Definition Overload.h:97
Definition Overload.h:69
RetType(* Callable)(ArgTypes...)
Definition Overload.h:70
UE_REWRITE constexpr RetType operator()(ArgTypes... Args) const
Definition Overload.h:72
Definition Overload.h:63