C++ variadic templates: elegant way of listing all array elements depending on variadic template size

  c++, variadic-templates

Is there some elegant way to express a function call depending on some n which can be derived from template arguments

f(my_array[0], ... , my_array[n-1]);

inside a class template looking like this?:

template <int... numbers>
class Abraham {
   static constexpr std::size_t n = sizeof...(numbers);
   some_type my_array[n];

   void foo(){
   //...
   f(my_array[0], ... , my_array[n-1]); // This line is no valid C++ Code. How can one achieve this in an elegant way?
   //...
   }
}

Source: Windows Questions C++

LEAVE A COMMENT