My question is in the code:
template
struct TupleOfVectors {
std::tuple...> tuple;
void do_something_t
Here's one approach which may work well in your case:
template
struct TupleOfVectors {
std::tuple...> tuple;
void do_something_to_each_vec()
{
// First template parameter is just a dummy.
do_something_to_each_vec_helper<0,Ts...>();
}
template
void do_something_to_vec()
{
auto &vec = std::get(tuple);
//do something to vec
}
private:
// Anchor for the recursion
template
void do_something_to_each_vec_helper() { }
// Execute the function for each template argument.
template
void do_something_to_each_vec_helper()
{
do_something_to_each_vec_helper<0,Args...>();
do_something_to_vec();
}
};
The only thing that is a bit messy here is the extra dummy int
template parameter to do_something_to_each_vec_helper
. It is necessary to make the do_something_to_each_vec_helper still be a template when no arguments remain. If you had another template parameter you wanted to use, you could use it there instead.