[c++] std::index_sequence
Usage:
template <typename... T>
void doSomething(T&&... args) {
using indices = std::index_sequence_for<T...>;
// Use indices to expand args pack
// ...
}
In the above example, std::index_sequence_for
generates an index_sequence
with indices from 0 to sizeof…(T) - 1. This can be used to expand parameter packs or access elements in a tuple or array.
std::index_sequence
and its related utilities provide a powerful mechanism for metaprogramming in C++.
For more information, you can refer to the C++ reference for std::index_sequence.