title: For loop over template arguments/types
body: <p>I want to write benchmark code for several combinations of several possible classes. If I write each combination myself it becomes an unmaintainable mess. Thus I'm looking for a way to automatically combine each type via templates, something akin to the following pseudo code:</p>
  
  <pre><code>for (typename HashFuction : Sha256, Sha512, Sa512_256, Sha3_256, Sha3_512) {
     for (typename KeyingWrapper : TwoPassKeyedHash, OnePassKeyedHash, PlainHash) {
        for (typename InstantiatedGetLeaf: GetLeaf&lt;8&gt;, GetLeaf&lt;1024&gt;) {
           for (typename algorithm : algA, algB, algC) {
              runAndTime&lt;HashFunction,KeyingWrapper,
                         InstantiatedGetLeaf,algorithm&gt;(someArgs);
           }
         }
      }
   }
  </code></pre>
  
  <p>Where <code>Sha256</code>,… ,<code>TwoPassKeyedHash</code>,…  are types.</p>
  
  <p>The code I'm looking for is supposed to be functionally equivalent to the following:</p>
  
  <pre><code>runAndTime&lt;Sha256,TwoPassKeyedHash,GetLeaf&lt;8&gt;,algA&gt;(someArgs);
  runAndTime&lt;Sha256,TwoPassKeyedHash,GetLeaf&lt;8&gt;,algB&gt;(someArgs);
  runAndTime&lt;Sha256,TwoPassKeyedHash,GetLeaf&lt;8&gt;,algC&gt;(someArgs);
  
  runAndTime&lt;Sha256,TwoPassKeyedHash,GetLeaf&lt;1024&gt;,algA&gt;(someArgs);
  runAndTime&lt;Sha256,TwoPassKeyedHash,GetLeaf&lt;1024&gt;,algB&gt;(someArgs);
  runAndTime&lt;Sha256,TwoPassKeyedHash,GetLeaf&lt;1024&gt;,algC&gt;(someArgs);
  
  runAndTime&lt;Sha256,OnePassKeyedHash,GetLeaf&lt;8&gt;,algA&gt;(someArgs);
  runAndTime&lt;Sha256,OnePassKeyedHash,GetLeaf&lt;8&gt;,algB&gt;(someArgs);
  runAndTime&lt;Sha256,OnePassKeyedHash,GetLeaf&lt;8&gt;,algC&gt;(someArgs);
  
  // And 99 further lines…
  </code></pre>
  
  <p>With Peregring-lk's help I have come as far as</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  template&lt;typename Aux_type&gt;
  void test_helper()
  {}
  
  template&lt;typename Aux_type, typename Head, typename... Tail&gt;
  void test_helper() {
     std::cout &lt;&lt; Head::i;
     test_helper&lt;Aux_type, Tail...&gt;();
  }
  
  template&lt;typename... Args&gt;
  void test()
  {
      test_helper&lt;void, Args...&gt;();
  }
  
  struct A{
     static const int i=1;
  };
  
  struct B{
     static const int i=2;
  };
  
  int main() {
     test&lt;A, B&gt;();
     return 0;
  }
  </code></pre>
  
  <p>but I don't yet see how I could iterate that recursion to get nested loops. Any help would be appreciated.</p>
  
  <p>(Edit: Code restructuring and inclusion of Peregring-lk's answer.)</p>