title: Is it a bad practice to always capture all in a lambda expression?
body: <pre><code>std::function&lt;int()&gt; void f1()
  {
      int a, b, c, d, ..., x, y, z;
  
      return [=] { return a + b + c; };
  }
  </code></pre>
  
  <p>vs.</p>
  
  <pre><code>std::function&lt;int()&gt; void f2()
  {
      int a, b, c, d, ..., x, y, z;
  
      return [a, b, c] { return a + b + c; };
  }
  </code></pre>
  
  <p>Needless to say, the former is shorter, handier, and more elegant than the latter.</p>
  
  <p>However, I still worry: </p>
  
  <p>From the performance viewpoint, is the latter always better than the former?</p>
  
  <p>Does the standard guarantee a lambda expression captures the necessary variables only? i.e. In the former example, only a, b, c are captured, the unused variables d, ..., x, y, z are not.</p>