title: Why lambda captures only automatic storage variables?
body: <p>I just started learning lambda functions in C++ and i don't understand why lambda's allow capturing only automatic storage variables? For example:</p>
  
  <pre><code>int x;
  int main() {
      [&amp;x](int n){x = n;}; // 'x' cannot be captured...
      return 0;
  }
  </code></pre>
  
  <p>On the other hand static variables don't need capturing at all</p>
  
  <pre><code>static int s = 0;
  [](int n){s = n;};
  </code></pre>
  
  <p>So, why the first example is not allowed and the second works?</p>