diff --git a/include/utempl/type_list.hpp b/include/utempl/type_list.hpp index bb1c075..1268963 100644 --- a/include/utempl/type_list.hpp +++ b/include/utempl/type_list.hpp @@ -97,4 +97,23 @@ consteval auto Size(TypeList) -> std::size_t { return sizeof...(Ts); }; +template +consteval auto TakeFrom(TypeList list) + requires(N + From <= sizeof...(Ts)) +{ + return [&](std::index_sequence) -> TypeList(list))...> { + return {}; + }(std::make_index_sequence()); +}; + +template +consteval auto PushTo(TypeList list) { + return TakeFrom(list) + kType + TakeFrom(list); +}; + +template +consteval auto Erase(TypeList list) { + return TakeFrom(list) + TakeFrom(list); +}; + } // namespace utempl diff --git a/include/utempl/utils.hpp b/include/utempl/utils.hpp index 34d3d86..e3a78f4 100644 --- a/include/utempl/utils.hpp +++ b/include/utempl/utils.hpp @@ -597,4 +597,13 @@ inline constexpr auto Generate(T&& value) { } | kSeq; }; +template +constexpr auto Enumerate(Tuple&& tuple) { + return Unpack(std::forward(tuple), [](auto&&... vs) { + return [&](auto... is) { + return MakeTuple(std::pair{*is, std::forward(vs)}...); + } | kSeq; + }); +}; + } // namespace utempl