mercredi 26 août 2015

Variadic templates of Variadic templates class in c++

given Variadic templates data structure as below ( code from Eli Bendersky's website):

template <class... Ts> struct tuple {};

template <class T, class... Ts>
struct tuple<T, Ts...> : tuple<Ts...> {
  tuple(T t, Ts... ts) : tuple<Ts...>(ts...), tail(t) {}

  T tail;
};

we are able to define something like

tuple<double, uint64_t, const char*> t1(12.2, 42, "big");

Then how to define a template structure that could accept following signature?

Foo<tuple<int,double>, tuple<double,int,long> ...,  tuple<std::string>> foo;

I think it would be like this:

template<tuple<class... Ts>... Tuples>
struct VariadicTuples {};

but it cannot compile. is that because the class in the Variadic templates cannot be Variadic templates? If so, How to make this work?

Aucun commentaire:

Enregistrer un commentaire