Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using std::tuple to construct a vector-based dataset refer to variadic-templates

I want make a class template like below:

template < typename... Args > class VectorTuple;

by example,

VectorTuple < long, double, string >

will instanced as

Tuple < vector < long >, vector < double > , vector < string > >

I am not familiar to variadic-templates. The worst method is to copy code from < tuple > and modify it. Is there an easy way to just directly use std::tuple to define my VectorTuple.

like image 780
spiritwalker Avatar asked Apr 25 '16 06:04

spiritwalker


1 Answers

If you are looking for typedef the variadic-templates type then,

template<typename... Args>
using VectorTuple = std::tuple<std::vector<Args>...>;

Now you can use it like

VectorTuple<long, double, std::string> obj;
like image 97
Praveen Avatar answered Sep 22 '22 23:09

Praveen