title: Variadic Templates - different types of expansion
body: <p>Andrei Alexandrescu gave an excellent talk entitled: <a href="http://channel9.msdn.com/Events/GoingNative/GoingNative-2012/Variadic-Templates-are-Funadic">Variadic Templates are Funadic</a>.</p>
  
  <p>He presents the following 3 expansions which are subltey different:</p>
  
  <pre><code>template &lt;class... Ts&gt; void fun( Ts... vs ) {
      gun( A&lt;Ts...&gt;::hun(vs)...);
      gun( A&lt;Ts...&gt;::hun(vs...));
      gun( A&lt;Ts&gt;::hun(vs)...);
  }
  </code></pre>
  
  <p>He explains:</p>
  
  <p><strong>Call 1:</strong>
  Expands all <code>Ts</code> for instatiation of <code>class A</code>,
  Then calls <code>hun(vs)</code> 
  Then expands all parameters again when passing them into <code>gun</code></p>
  
  <p><strong>Call 2:</strong>
  Expands all <code>Ts</code> and all <code>vs</code> separately</p>
  
  <p><strong>Call 3:</strong>
  Expnads in lock step, ie:
  Expand argument 1 of <code>Ts</code> and Argument 1 of <code>vs</code>
  Expand argument 2 of <code>Ts</code> and Argument 2 of <code>vs</code>
  Expand argument n of <code>Ts</code> and Argument n of <code>vs</code></p>
  
  <p>Other discussion on variadic templates only seem to cover the simple variadic class templates and variadic functions such as typesafe printf etc. I am unsure as to how these different types of expansion effect the code and where each type would be useful.</p>
  
  <p>Does anyone have some examples that demonstrate the application of each type of expansion?</p>