title: Implementing variadic type traits
body: <h2>Intro</h2>
  
  <p>I'm looking for <strong>a pattern</strong> to convert C++ type traits into their <strong>variadic counterparts</strong>. A <strong>methodology</strong> to approach the problem would be appreciated and <strong>generative programming</strong> patterns to automate the task would be ideal. </p>
  
  <h2>Example</h2>
  
  <p>Take the following : </p>
  
  <pre><code>std::is_same&lt;T, U&gt;::value; 
  </code></pre>
  
  <p>I want to write a trait that works like so :</p>
  
  <pre><code>std::are_same&lt;T1, T2, T3, T4&gt;::value; 
  </code></pre>
  
  <hr>
  
  <h2>Current approach</h2>
  
  <p>It's pretty <a href="http://ideone.com/QZk600"><strong>straightforward</strong></a> to implement the <code>are_same</code>; <strong>Seeking a general solution</strong> we can come up with a tool for any variadic trait implementing <strong>universal quantification</strong> : </p>
  
  <pre><code>template&lt;template&lt;class,class&gt; class F, typename...Ts&gt;
  struct Univ;
  
  template&lt;template&lt;class, class&gt; class F, typename T, typename U, typename...Ts&gt;
  struct Univ&lt;F, T, U, Ts...&gt;
  {
      static const int value = F&lt;T, U&gt;::value &amp;&amp; Univ&lt;F, U, Ts...&gt;::value;
  };
  
  template&lt;template&lt;class, class&gt; class F, typename T&gt;
  struct Univ&lt;F, T&gt;
  {
      static const int value = 1;
  };
  </code></pre>
  
  <p>so that eg <code>are_same</code> could be <a href="http://ideone.com/fSv8GL"><strong>written as</strong></a></p>
  
  <pre><code>Univ&lt;is_same,int, int, int&gt;::value
  </code></pre>
  
  <p>and this could apply when creating traits like <code>are_classes</code>, <code>are_scalars</code> etc</p>
  
  <h2>Generalizing</h2>
  
  <p>Minor tweaks could give <strong>existential quantification</strong> out of the previous snippet (replacing <code>&amp;&amp;</code> with <code>||</code>) so that we create traits like <code>exist_same</code> in the following fashion : </p>
  
  <pre><code>Exist&lt;is_same, int, double, float&gt;::value
  </code></pre>
  
  <h2>Question</h2>
  
  <p>The previous cover generalization on <a href="http://en.cppreference.com/w/cpp/header/type_traits">type traits</a> related to </p>
  
  <ul>
  <li>Primary type categories</li>
  <li>Composite type categories</li>
  <li>Type properties</li>
  <li>Supported operations</li>
  </ul>
  
  <p><strong>How would I generalize for type traits</strong> like the following : </p>
  
  <pre><code>    enable_if -&gt; enable_if_any // enable if any clause is true
                   enable_if_all // enalbe if all clauses are true
                   enable_for    // enable only for the type provided
  </code></pre>
  
  <p><strong>The <code>exist_same</code></strong> example above is oversimplified. Any ideas for a correct implementation?</p>
  
  <p><strong>There are type_traits</strong> that "return" modified types. Any suggestion for scaling those to implementations for arbitrary number of types ? </p>
  
  <p><strong>Are there type_traits</strong> which are made <strong>not to scale to arbitrary number of type arguments</strong> ? </p>