From 149670fb2bf38dd4a38a3c0508fd0719fed7263d Mon Sep 17 00:00:00 2001 From: sha512sum Date: Sat, 23 Mar 2024 15:33:50 +0000 Subject: [PATCH] Fix find for TupleLike --- include/utempl/utils.hpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) 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