vendredi 24 novembre 2017

How to take nested parameter packs in variadic templates?

In what way can I express that each parameter in a parameter pack to a variadic template is itself a parameter pack?

Consider this code:

template <typename... TS>
void use_tuple(std::tuple<TS...> arg0);

template <typename... TS0, typename... TS1>
void use_tuple(std::tuple<TS0...> arg0, std::tuple<TS1...> arg1);

I want use_tuple to be able to take any number of tuples. Right now I have to write it like this:

template <typename... TS0, typename... REST>
void use_tuple(std::tuple<TS0...> arg0, REST... rest);

void use_tuple();  // Terminates the recursion.

But I want to write it like this:

// Each ELEMENT in PACK_OF_PACKS is a parameter pack.
template <(typename...)... PACK_OF_PACKS>
void use_tuple(std::tuple<PACK_OF_PACKS...>... args);

Is this even possible? If so, how? If not, what else can I do? My goal for this code is to get at the types contained in all the tuples.

Aucun commentaire:

Enregistrer un commentaire