After
P1061R10 has been approved for C++26, it's now time to let
std::integer_sequence be a destructurable type for improved usability while still remain its niche
auto [...Is] = std::make_index_sequence<N>();
This addition helps simplify metaprogramming implementations that rely on std::integer_sequence. Most of these implementations declare another helper function that takes std::integer_sequence that does the actual work. But with this addition, you don't need to do that.
// before:
template <typename Array, std::size_t... I>
constexpr auto array_to_tuple_impl(const Array& a, std::index_sequence<I...>)
{
return std::make_tuple(a[I]...);
}
template <typename T, std::size_t N, typename Indx = std::make_index_sequence<N>>
constexpr auto array_to_tuple(const std::array<T, N>& a)
{
return details::array_to_tuple_impl(a, Indx{});
}
// after:
template <typename T, std::size_t N>
constexpr auto array_to_tuple(const std::array<T, N>& a)
{
auto [...Is] = std::make_index_sequence<N>();
return std::make_tuple(a[Is]...);
}