Is it possible to write something like this?
[](std::index_sequence<std::size_t ...I> s) {
};
Or this?
[]<std::size_t ...I>(std::index_sequence<I...> s) {
}
How is the syntax for this in C++14 or C++17? Or is it not possible at all? Basically, I just want to have the I
as a template parameter pack, and the lambda just serves as a way to do that. Alternatively, is there a syntax to achieve the following?
std::index_sequence<std::size_t ...I> x = std::make_index_sequence<10>{};
// I now is a local template parameter pack
GCC provides the latter syntax as an extension, but it's not standard:
template <typename... Ts>
void foo(const std::tuple<Ts...>& t) {
auto l = [&t]<std::size_t ...I>(std::index_sequence<I...> s) {
std::initializer_list<int>{ (std::cout << std::get<I>(t), 0)... };
};
l(std::index_sequence_for<Ts...>{});
}
Live Demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With