title: C++14: How to group variadic inputs by template parameter?
body: <p>Say I have two classes:</p>
  
  <pre><code>template &lt;unsigned N&gt;
  class Pixel {
      float color[N];
  public:
      Pixel(const std::initializer_list&lt;float&gt; &amp;il)
      {
        // Assume this code can create a Pixel object from exactly N floats, and would throw a compiler error otherwise
  
      }
  };
  
  template &lt;unsigned N&gt;
  class PixelContainer {
      std::vector&lt;Pixel&lt;N&gt;&gt; container;
  };
  </code></pre>
  
  <p>What I'm trying to do is to write a constructor for <code>PixelContainer</code> such that:
  It would instantiate correctly for the following cases (example, not exhaustive):</p>
  
  <pre><code>PixelContainer&lt;3&gt; pc1(1, 2, 3)          // Creates a container containing one Pixel&lt;3&gt; objects
  PixelContainer&lt;3&gt; pc2(1, 2, 3, 4, 5, 6) // Creates a container containing 2 Pixel&lt;3&gt; objects
  PixelContainer&lt;2&gt; pc3(1, 2, 3, 4, 5, 6) // Creates a container containing 3 Pixel&lt;2&gt; objects
  </code></pre>
  
  <p>It would not compile for the following cases (as example, not exhaustive):</p>
  
  <pre><code>PixelContainer&lt;3&gt; pc4(2, 3) // Not enough arguments
  PixelContainer&lt;2&gt; pc5(1, 2, 3, 4, 5) // Too many arguments
  </code></pre>
  
  <p>How do I achieve the above using template meta-programming? I feel it should be achievable, but can't figure out how. Specifically, I do <strong>not</strong> want to be doing the grouping myself e.g </p>
  
  <pre><code>PixelContainer&lt;2&gt; pc2({1, 2}, {3, 4}, {5, 6}) // Creates a container containing 3 Pixel&lt;2&gt; objects
  </code></pre>
  
  <p>(See this <a href="https://stackoverflow.com/q/17607080/212942">question</a> for the inspiration behind mine)</p>