Put each variadic template argument into container

Is there a way in modern C++ to put each of the variadic template arguments into a container within a std::tuple? For example:

template<class ... T>
class MyClass {
private:
std::tuple<T...> myTuple;
};

int main() {
MyClass<int, char, float> test; //inner class stores an std::tuple<int, char, float>
//is there a way to make the inner class store std::tuple<std::vector<int>, std::vector<char>, std::vector<float>>
return 0;
}

Tuples do not have to be used, as long as I get a class with an end result of each variadic template argument being stored in a container like a std::vector.

Answer

is there a way to make the inner class store std::tuple<std::vector<int>, std::vector<char>, std::vector<float>

You have simply to unpack the T variadic list inside std::tuple<std::vector<...>>.

I mean

template<class ... T>
class MyClass {
   private:
      std::tuple<std::vector<T>...> myTuple;
}; // ...........^^^^^^^^^^^^^^

Leave a Reply

Your email address will not be published. Required fields are marked *