diff --git a/include/utempl/utils.hpp b/include/utempl/utils.hpp index a85134d..038793c 100644 --- a/include/utempl/utils.hpp +++ b/include/utempl/utils.hpp @@ -294,16 +294,25 @@ inline constexpr auto Curry(F&& f) -> Curryer> { template inline constexpr auto Find(Tuple&& tuple, T&& find) -> std::size_t { return [&](std::index_sequence) -> std::size_t { + using Type = std::remove_cvref_t; std::array> bs{Overloaded( - [&](const T& element){ + [&](const Type& element) { + return element == find; + }, + [&](const Type&& element) { + return element == find; + }, + [&](Type&& element) { + return element == find; + }, + [&](Type& element) { return element == find; }, [](auto&&) { return false; } - )(Get(tuple))...}; + )(Get(std::forward(tuple)))...}; return std::ranges::find(bs, true) - bs.begin(); }(std::make_index_sequence>()); }; - } // namespace utempl