title: Variadic template loop, non recursive
body: <p>I have some function, which performs complex drawings. [in pseudocode]</p>
  
  <pre><code>template&lt;typename fields...&gt;       // field names of Brush class
  void someFunction(){    
    for(very large loop){
  
       Brush brush = getBrush();
       int x;
  
       foreach(field : fields){     // &lt;--- this somehow should be replaced
          x = brush.*field;
          brush.update(x);
       }
  
    }    
  }
  </code></pre>
  
  <p>[listing 1]</p>
  
  <p>I call it:</p>
  
  <pre><code>someFunction&lt;&amp;Brush::xPos1, &amp;Brush::xPos2, &amp;Brush::xPos3, &amp;Brush::xPos4&gt;()
  </code></pre>
  
  <p>And I want compiler to generate something like this:</p>
  
  <pre><code>void someFunction(){    
    for(very large loop){
  
       Brush brush = getBrush();
       int x;
  
          x = brush.xPos1;
          brush.update(x);
  
          x = brush.xPos2;
          brush.update(x);
  
          x = brush.xPos3;
          brush.update(x);
  
          x = brush.xPos4;
          brush.update(x);
  
    }    
  }
  </code></pre>
  
  <p>[listing 2]</p>
  
  <p>I mean, I want to get rid of that foreach(field : fields).</p>
  
  <hr>
  
  <p>I found this variadic template loop implementation, but it is recursive. For performance resons this even worst than foreach loop</p>
  
  <pre><code>int a;
  
  template &lt;class T&gt;
  void print(const T msg)
  {
      a = msg;
  }
  
  
  // And this is the recursive case:
  template &lt;class A, class... B&gt;
  void print(A head, B... tail)
  {
      a = head;
    print(head);
    print(tail...);
  }
  </code></pre>
  
  <p>[listing 3]</p>
  
  <hr>
  
  <p>So the question is.... Is it possible possible to achive result as on [listing 2]? If yes, than how?</p>