0

Could one make a variadic template template, itself with variadic parameters?
How would one explicitly/partially specialize this template?

//E.g. something where the following would be valid:

template <template <typename...> typename... Containers>
    class SomeClass {};

SomeClass <int, std::vector<int>, std::tuple<int, char, float, double, short>> var;

I get as far as

template <template <typename...> typename... Tuples>
    class CVarMap : public CVarMap<Tuples>
    {};

template <template <typename...> typename Tuple, template <typename...> typename... Tuples>
    class CVarMap : public CVarMap<Tuple, Tuples...>
    {};

but any attempt to unpack the "inner" variadic args results in a template with multiple variadic parameters. Yet in the answer for this question there are multiple variadic parameters, which is valid.

What am I missing here?

SKNB
  • 75
  • 2
  • 9
  • From definition, `var` is invalid, `SomeClass` would be though. – Jarod42 Apr 11 '23 at 16:05
  • 2
    I'm pretty sure this is not possible. Do you really need template template paramters? `template class SomeClass {};` lets you have `SomeClass , std::tuple> var;` – NathanOliver Apr 11 '23 at 16:06
  • `int, std::vector, std::tuple` are all types. `std::vector, std::tuple` are `template typename`s – Caleth Apr 11 '23 at 16:06
  • `class CVarMap : public CVarMap` would be self inheritance... – Jarod42 Apr 11 '23 at 16:07
  • What are you wanting to do with `Containers...` in the body of `SomeClass`? – Caleth Apr 11 '23 at 16:09
  • @Jarod42 because of the `int`? – SKNB Apr 11 '23 at 17:42
  • @NathanOliver I was wondering if it was possible. As to whether one *should*... – SKNB Apr 11 '23 at 17:44
  • @Caleth it was mostly an academic exercise, I see that it is not inadvisable but actually impossible. – SKNB Apr 11 '23 at 18:10
  • I still don't understand what the OP is trying to do. Why would `int` be a valid template argument to `SomeClass`, if `SomeClass` is supposed to take variadic templates as arguments? – Brian Bi Apr 12 '23 at 01:48
  • @SKNB: not only because of the `int`. As we said `` is for types like `int`, `std::vector`, `std::tuple`; – Jarod42 Apr 12 '23 at 12:28

0 Answers0