mercredi 27 mai 2015

Variadic Template Parameter Packs with Alternating Types

I was wondering if it is possible to capture an alternating parameter pattern using a parameter pack. For example,

template<typename T, size_t U, typename... Args>
class foo<T, U, Args...>
{
   public:
     foo() : my_T(nullptr), my_U(U) {}

   private:
     T* my_T;
     size_t my_U;
     foo<Args...> my_next_foo;
}

So this doesn't work since Args is a parameter pack of only types. Is there a may to modify this so that the typename T, size_t U pattern can be properly captured in a variadic template? Thanks

Aucun commentaire:

Enregistrer un commentaire