title: Understanding C++ variable number of input parameters to test_function(Test<T>...)
body: <p>I have a generic class <code>Test&lt;T&gt;</code> and I want to have a function <code>test_function()</code> that has a variable number of <code>Test&lt;T&gt;</code> object input parameters with <code>...</code>. In the function, I want to iterate over all the parameters. The generic type <code>T</code> can be different across the parameters. Something like this:</p>
  <pre class="lang-cpp prettyprint-override"><code>template &lt;typename T&gt; class Test {
  private:
      T value = (T)0;
      int test = 1;
  public:
      Test() = default;
      int get_test() {
          return test;
      }
  }
  
  template &lt;typename T&gt; void test_function(const Test&lt;T&gt; tests...) {
      for(auto test : tests) {
          cout &lt;&lt; test.get_test() &lt;&lt; endl;
      }
  }
  </code></pre>
  <p>When compiling, I get the errors:</p>
  <pre class="lang-none prettyprint-override"><code>error C3520: &quot;T&quot;: Parameter pack must be extended in this context
  error C3520: &quot;tests&quot;: Parameter pack must be extended in this context
  error C3312: no callable 'begin' function found for type 'unknown-type'
  error C3312: no callable 'end' function found for type 'unknown-type'
  </code></pre>
  <p>What am I doing wrong?</p>
  <p>EDIT: Is it possible to have a counter in the expansion?</p>
  <p>EDIT 2: I figured it out with the counter:</p>
  <pre class="lang-cpp prettyprint-override"><code>template &lt;typename ...T&gt; void test_function(const Test&lt;T&gt; ...tests) {
      int i=0;
      ((cout &lt;&lt; tests.get_test() &lt;&lt; &quot;, counter = &quot; &lt;&lt; i++ &lt;&lt; endl), ...);
  }
  </code></pre>