Add PackConstexprWrapper

This commit is contained in:
sha512sum 2024-06-11 07:57:56 +00:00
parent a767c7637a
commit 024dbaf525

View file

@ -20,6 +20,10 @@ struct Wrapper {
};
};
template <auto Value>
inline constexpr Wrapper<Value> kWrapper;
template <ConstexprString string, typename T = std::size_t>
consteval auto ParseNumber() -> T {
T response{};
@ -343,9 +347,17 @@ inline constexpr auto Map(F&& f, TypeList<R> result = {}) {
};
};
template <auto Tuple>
consteval auto PackConstexprWrapper() {
return [&]<std::size_t... Is>(std::index_sequence<Is...>) {
return MakeTuple<decltype(Tuple)>(kWrapper<Get<Is>(Tuple)>...);
}(std::make_index_sequence<kTupleSize<decltype(Tuple)>>());
};
template <TupleLike Tuple>
inline constexpr auto Reverse(Tuple&& tuple) {
return [&]<auto... Is>(std::index_sequence<Is...>) {
return [&]<std::size_t... Is>(std::index_sequence<Is...>) {
return MakeTuple<Tuple>(Get<kTupleSize<Tuple> - Is - 1>(std::forward<Tuple>(tuple))...);
}(std::make_index_sequence<kTupleSize<Tuple>>());
};