title: How does folding over comma work?
body: <p>How does the following line unfold? </p>
  
  <pre><code>template &lt;class... Ts&gt;
  void print_all(std::ostream&amp; os, Ts const&amp;... args) {
      (void(os &lt;&lt; args), ...);
  }
  </code></pre>
  
  <p>Applying the rule, </p>
  
  <blockquote>
    <p>Unary right fold (E op ...) becomes E<sub>1</sub> op (... op (E<sub>N-1</sub> op E<sub>N</sub>))</p>
  </blockquote>
  
  <p>provided by <a href="http://en.cppreference.com/w/cpp/language/fold" rel="noreferrer">cppreference</a>,  </p>
  
  <pre><code>E  = void(os &lt;&lt; args)
  op = , 
  </code></pre>
  
  <p>Then the expansion becomes</p>
  
  <pre><code>void(os &lt;&lt; args[0], ..., (args[N-3], (args[N-2], args[N-1])) )
  </code></pre>
  
  <p>?</p>
  
  <p>How about </p>
  
  <pre><code>v.push_back(args), ...
  </code></pre>
  
  <p>Does it become</p>
  
  <pre><code>v.push_back(args[0], (args[1], ..., (args[N-2], args[N-1])))
  </code></pre>
  
  <p>Both the expansion and the parenthesis are confusing.  Would someone explain?</p>