title: C++ lambda value can't capture
body: <p>Here is my code,I want to test closure in c++ like javascript. Why the compiler yield this message?     "testLambda.cpp: In lambda function:
      testLambda.cpp:8:11: error: ‘a’ is not captured"</p>
  
  <pre><code>    #include &lt;iostream&gt;
      #include &lt;functional&gt;
      std::function&lt;bool(int)&gt; returnLambda(int a){
          auto b  = 1;
          auto c  = 2;
  
          return [&amp;](int x)
          {   return x*(b++)+c+a == 0;};
      }
      auto f = returnLambda(21);
      int main(){
          auto c = f(1);
          auto b = f(1);
  
          std::cout&lt;&lt;c&lt;&lt;b&lt;&lt;std::endl;
          return 0;
      }
  </code></pre>