From cf3d5509b100fa32667c347b8a2aabea7ea176e0 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Sun, 23 Nov 2025 18:47:49 -0600 Subject: [PATCH] Common: Make a void-returning MoveOnlyFunction able to accept a non-void-returning function object and just drop the return value. std::function behaves this way. --- Source/Core/Common/Functional.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/Core/Common/Functional.h b/Source/Core/Common/Functional.h index 7f96664041..bde566ae7c 100644 --- a/Source/Core/Common/Functional.h +++ b/Source/Core/Common/Functional.h @@ -45,7 +45,13 @@ private: struct Func : FuncBase { explicit Func(F&& f) : func{std::forward(f)} {} - result_type Invoke(Args... args) override { return func(std::forward(args)...); } + result_type Invoke(Args... args) override + { + if constexpr (std::is_void_v) + func(std::forward(args)...); + else + return func(std::forward(args)...); + } std::decay_t func; };