I have a function template:
template <typename... Us>
void set_args(const void* p, Us&... args);
I have a std::tuple
that I want to unpack into args
. My current solution is
template <typename... Us, std::size_t... Idx>
void set_args_2(
const void* p, std::tuple<Us...>& args, std::index_sequence<Idx...>) {
set_args(p, std::get<Idx>(args)...);
}
template <typename... Us>
void func(std::tuple<Us...>& args, ...) {
...
set_args_2(p, args, std::index_sequence_for<Us...>{});
...
}
Note the artificial set_args_2()
that is purely there to get Idx
to unpack the tuple. Is there a way to unpack the tuple in-place func()
, so that set_args()
can be called directly?