title: Specifying a lambda function as default argument
body: <p>How do I assign a lambda as default argument? I would like to do this:</p>
  
  <pre><code>int foo(int i, std::function&lt;int(int)&gt; f = [](int x) -&gt; int { return x / 2; })
  {
      return f(i);
  }
  </code></pre>
  
  <p>but my compiler (g++ 4.6 on Mac OS X) complains:</p>
  
  <pre><code>error: local variable 'x' may not appear in this context
  </code></pre>
  
  <p><strong>EDIT</strong>:
  Indeed, this was a compiler bug. The above code works fine with a recent version of gcc (4.7-20120225).</p>