Given a variadic template, I would like to define an object that would be a tuple of vector of each type in the variadic template.
Something like:
template <typename... Ts>
class C {
std::tuple<std::vector<T1>, std::vector<T2>,...,std::vector<Tn>> vectors;
};
It does not have to be one data member, I mean, if it is possible to accomplish this using more auxiliary types or objects, that would not be a problem.
I tried a combination of std::make_index_sequence
with std::tuple
, but I could not figure it out.
You don't have to use a class here, you can make use of a simple type-alias template:
template<typename... Ts>
using VectorTuple = std::tuple<std::vector<Ts>...>;
template <typename... Ts>
class C {
std::tuple<std::vector<Ts>...> vectors;
};
This expands the pattern (std::vector<Ts>
) for each type in the pack (resulting in your desired std::tuple<std::vector<T1>, std::vector<T2>,...,std::vector<Tn>>
)
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