title: unpacking values of an array as parameters to a variadic function
body: <p>I am trying (at compile time) to unpack integers as arguments to a variadic function. The idea would be to have those values packed in an array or in a <code>std::index_sequence</code> (c++14) at compile time. I have tried to use some of the answers from older posts, but I find the example code unreadable for my level.</p>
  
  <p>Here is a simple example with the functionality that I need to implement in a code that I am writing, in this case attempting to use <code>std::make_index_sequence</code>. I do not necessarily need to use the latter. The problem is that the values of the sequence are not unpacked as arguments to the variadic function:</p>
  
  <pre><code>#include &lt;cstdio&gt;
  #include &lt;iostream&gt;
  #include &lt;utility&gt;
  
  using namespace std;
  
  
  void print(const int &amp;val){
    cout &lt;&lt; val &lt;&lt; endl;
  }
  
  template&lt;typename ...S&gt; void print(const int &amp;val, const S&amp;... others)
  {
    print(val);
    print(others...);
  }
  
  template&lt;size_t n&gt; void printNumbers(){
    std::make_index_sequence&lt;n&gt; a;
    print(a);
  }
  
  
  int main(){
    printNumbers&lt;6&gt;();
  }
  </code></pre>
  
  <p>The output from GCC8:</p>
  
  <pre><code>    tet.cc: In instantiation of ‘void printNumbers() [with long unsigned int n = 6]’:
  tet.cc:25:19:   required from here
  tet.cc:20:8: error: no matching function for call to ‘print(std::make_index_sequence&lt;6&gt;&amp;)’
     print(a);
     ~~~~~^~~
  tet.cc:8:6: note: candidate: ‘void print(const int&amp;)’
      void print(const int &amp;val){
       ^~~~~
  tet.cc:8:6: note:   no known conversion for argument 1 from ‘std::make_index_sequence&lt;6&gt;’ {aka ‘std::integer_sequence&lt;long unsigned int, 0, 1, 2, 3, 4, 5&gt;’} to ‘const int&amp;’
  tet.cc:12:30: note: candidate: ‘template&lt;class ... S&gt; void print(const int&amp;, const S&amp; ...)’
  template&lt;typename ...S&gt; void print(const int &amp;val, const S&amp;... others)
                                   ^~~~~
  tet.cc:12:30: note:   template argument deduction/substitution failed:
  tet.cc:20:9: note:   cannot convert ‘a’ (type ‘std::make_index_sequence&lt;6&gt;’ {aka ‘std::integer_sequence&lt;long unsigned int, 0, 1, 2, 3, 4, 5&gt;’}) to type ‘const int&amp;’
  </code></pre>