UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
OverrideVoidReturnInvoker.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5// HEADER_UNIT_SKIP - Not included directly
6
7#include "CoreTypes.h"
8#include <type_traits>
9
14template <typename ReturnType, typename FuncType>
16{
21
22 template <typename... ArgTypes>
23 bool operator()(ArgTypes&&... Args)
24 {
25 using FuncResultType = std::invoke_result_t<FuncType, ArgTypes...>;
26 static_assert(std::disjunction_v<std::is_same<FuncResultType, void>, std::is_same<FuncResultType, ReturnType>>, "Passed in function should either return void or ReturnType");
27
28 if constexpr (std::is_same_v<FuncResultType, void>)
29 {
31 return DefaultValue;
32 }
33 else
34 {
35 return Invoke(Function, Forward<ArgTypes>(Args)...);
36 }
37 }
38
39 ReturnType DefaultValue;
40 FuncType Function;
41};
AUTORTFM_INFER UE_FORCEINLINE_HINT constexpr auto Invoke(FuncType &&Func, ArgTypes &&... Args) -> decltype(((FuncType &&) Func)((ArgTypes &&) Args...))
Definition Invoke.h:44
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition OverrideVoidReturnInvoker.h:16
FuncType Function
Definition OverrideVoidReturnInvoker.h:40
bool operator()(ArgTypes &&... Args)
Definition OverrideVoidReturnInvoker.h:23
TOverrideVoidReturnInvoker(ReturnType InDefaultValue, FuncType InFunction)
Definition OverrideVoidReturnInvoker.h:17
ReturnType DefaultValue
Definition OverrideVoidReturnInvoker.h:39