title: Check traits for all variadic template arguments
body: <p><strong>Background :</strong> I've created the following class <code>C</code>, whose constructor should take <code>N</code> variables of type <code>B&amp;</code> :</p>
  
  <pre><code>class A;
  class B
  {
      A* getA();
  };
  
  template&lt;size_t N&gt;
  class C
  {
  public:
      template&lt;typename... Args&gt;
      inline C(Args&amp;... args) :
          member{args.getA()...}
      {}
  private:
      std::array&lt;A*, N&gt; member;
  };
  </code></pre>
  
  <p><strong>Problem :</strong> my problem is how to constraint the variadic <code>Args</code> to be all of type <code>B</code> ?</p>
  
  <p><strong>My partial solution :</strong> I wanted to define a predicate like :</p>
  
  <pre><code>template &lt;typename T, size_t N, typename... Args&gt;
  struct is_range_of :
      std::true_type // if Args is N copies of T
      std::false_type // otherwise
  {};
  </code></pre>
  
  <p>And redefine my constructor accordingly :</p>
  
  <pre><code>template &lt;typename... Args,
            typename = typename std::enable_if&lt;is_range_of_&lt;B, N, Args...&gt;::value&gt;::type
           &gt;
  inline C(Args&amp;... args);
  </code></pre>
  
  <p>I've seen a possible solution on this post : <a href="https://stackoverflow.com/a/11414631">https://stackoverflow.com/a/11414631</a>, which defines a generic <code>check_all</code> predicate :</p>
  
  <pre><code>template &lt;template&lt;typename&gt; class Trait, typename... Args&gt;
  struct check_all :
      std::false_type
  {};
  
  template &lt;template&lt;typename&gt; class Trait&gt;
  struct check_all&lt;Trait&gt; :
      std::true_type
  {};
  
  template &lt;template&lt;typename&gt; class Trait, typename T, typename... Args&gt;
  struct check_all&lt;Trait, T, Args...&gt; :
      std::integral_constant&lt;bool, Trait&lt;T&gt;::value &amp;&amp; check_all&lt;Trait, Args...&gt;::value&gt;
  {};
  </code></pre>
  
  <p>So, I could write something like :</p>
  
  <pre><code>template &lt;typename T, size_t N, typename... Args&gt;
  struct is_range_of :
      std::integral_constant&lt;bool,
          sizeof...(Args) == N &amp;&amp;
          check_all&lt;Trait, Args...&gt;::value
      &gt;
  {};
  </code></pre>
  
  <p><strong>Question 1 :</strong> I don't know how to define the <code>Trait</code>, because I need somehow to bind <code>std::is_same</code> with <code>B</code> as first argument. Is there any means of using the generic <code>check_all</code> in my case, or is the current grammar of C++ incompatible ?</p>
  
  <p><strong>Question 2 :</strong> My constructor should also accept derived classes of <code>B</code> (through a reference to <code>B</code>), is it a problem for template argument deduction ? I am afraid that if I use a predicate like <code>std::is_base_of</code>, I will get a different instantiation of the constructor for each set of parameters, which could increase compiled code size...</p>
  
  <p><em>Edit :</em> For example, I have <code>B1</code> and <code>B2</code> that inherits from <code>B</code>, I call <code>C&lt;2&gt;(b1, b1)</code> and <code>C&lt;2&gt;(b1, b2)</code> in my code, will it create two instances (of <code>C&lt;2&gt;::C&lt;B1, B1&gt;</code> and <code>C&lt;2&gt;::C&lt;B1, B2&gt;</code>) ? I want only instances of <code>C&lt;2&gt;::C&lt;B, B&gt;</code>.</p>