With std::tupleyou can do
struct A {
template <class T>
T getFirstElement() const
{
return std::get<std::vector<T>>(Vectors)[0];
}
std::tuple<std::vector<float>, std::vector<int>> Vectors;
};
And with a variation pattern:
template <typename ... Ts>
struct A_impl {
template <class T>
T getFirstElement() const
{
return std::get<std::vector<T>>(Vectors)[0];
}
std::tuple<std::vector<Ts>...> Vectors;
};
struct A : A_impl<float, int> {};
source
share