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(); }