dimanche 5 novembre 2017

converting parameter pack into a vector

I am trying to understand variadic templates in C++ and I am lost in the following example: Imagine a function foo(T, T, T, T) which takes variadic number of arguments of the same type T and converts them into a vector. Something like

template<typename T, T ...Is>
void foo() {

   std::vector<T> x;

   for( auto xx:x ) {
      std::cout << xx << std::endl;
   }

   return;
}

Aucun commentaire:

Enregistrer un commentaire