mercredi 27 juillet 2016

Variadic variadic template template parameters

Is there a straightforward way to have variadic variadic template template parameters. For instance consider the following function signature

template<template<typename,size_t...> class Pack, 
  typename T, size_t ... Args>
void foo(const Pack<T,Args...>& a);

If we want to pass two Packs we have to now do an overload

template<template<typename,size_t...> class Pack, 
  typename T, size_t ... Args0, size_t ... Args1>
void foo(const Pack<T,Args0...>& a, const Pack<T,Args1...>& b);

Now what if we want to pass a variable number of objects of Pack with different variadic parameters e.g. Args0...,Args1...,Args2....

So I was thinking if there is a practical way of doing something along the lines of (the following is certainly a sketch representation).

template<template<typename,size_t...> ... class Pack, typename T,...>  
void foo(const Pack<T,...> ... packs);

Aucun commentaire:

Enregistrer un commentaire