Function with a fixed amount of parameters determined by an integer : <p>I have a class with a template that accepts an integer:</p>

<pre><code>template &lt;unsigned int N&gt;
class Example {};
</code></pre>

<p>I'm looking for a way to define a (member)function that accepts some amount of <code>Example</code> objects as arguments. The amount is to be determined by <code>N</code>, so the function would be used like this:</p>

<pre><code>Function(Example&lt;2&gt;(), Example&lt;2&gt;());
Function(Example&lt;3&gt;(), Example&lt;3&gt;(), Example&lt;3&gt;());
</code></pre>

<p><strong>What I tried so far:</strong></p>

<p>Using an initializer list, one is able to pass a set of objects to the function:</p>

<pre><code>template &lt;unsigned int N&gt;
void Function(std::initializer_list&lt;Example&lt;N&gt;&gt; list);
//...
Function({Example&lt;2&gt;(), Example&lt;2&gt;()});
</code></pre>

<p>However, the problem besides the fact that really only one argument is passed(the list), is that with this method any number of arguments can be used:</p>

<pre><code>Function({Example&lt;2&gt;()});
</code></pre>

<p>I also tried using a variadic function:</p>

<pre><code>template &lt;unsigned int N&gt;
void Function(Example&lt;N&gt; e...)
{
    va_list args;
    va_start(args, e);
    //...
}
Function(Example&lt;2&gt;(), Example&lt;2&gt;());
</code></pre>

<p>This makes it possible to use real parameters, but the problem of using any number of arguments remains, and it's not possible to know how many arguments were actually passed.</p>
