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