From d67973d1181ff986ba63c756b47cc854f4d51d32 Mon Sep 17 00:00:00 2001 From: neargye Date: Wed, 4 Oct 2023 19:14:27 +0400 Subject: [PATCH] fix Argument-dependent lookup results in enum_switch --- include/magic_enum_switch.hpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/include/magic_enum_switch.hpp b/include/magic_enum_switch.hpp index e91a75337..1cae014ef 100644 --- a/include/magic_enum_switch.hpp +++ b/include/magic_enum_switch.hpp @@ -101,22 +101,13 @@ inline constexpr auto default_result_type_lambda = []() noexcept(std::is_nothrow template <> inline constexpr auto default_result_type_lambda = []() noexcept {}; -template -constexpr R invoke_r(F&& f, Args&&... args) noexcept(std::is_nothrow_invocable_r_v) { - if constexpr (std::is_void_v) { - std::forward(f)(std::forward(args)...); - } else { - return static_cast(std::forward(f)(std::forward(args)...)); - } -} - template constexpr decltype(auto) constexpr_switch_impl(F&& f, E value, Def&& def) { if constexpr(I < End) { constexpr auto v = enum_constant()>{}; if (value == v) { if constexpr (std::is_invocable_r_v) { - return invoke_r(std::forward(f), v); + return static_cast(std::forward(f)(v)); } else { return def(); }