title: Pass lambda expression to lambda argument c++11
body: <p>I would like to do something like this:</p>
  
  <pre><code>int main()
  {
      auto f = [/*some variables*/](/*take lambda function*/)
      {/*something with lambda function*/};
  
      f([/*other variables*/](/*variables to be decided by f()*/)
      {/*something with variables*/});
  }
  </code></pre>
  
  <p>I know that it is possible to pass a lambda to a function, as well as to a lambda.
  The following works:</p>
  
  <pre><code>int main()
  {
      int x=0;
      int y=0;
      auto f = [x,y](double (func)(int)) -&gt; double
      {func(0); return 0.0;};
  
      f([](int i) -&gt; double
      {return 0.0;});
  }
  </code></pre>
  
  <p>But the following does not work (as soon as i change the scope variables to add [x])</p>
  
  <pre><code>int main()
  {
      int x=0;
      int y=0;
      auto f = [x,y](double (func)(int)) -&gt; double
      {func(0); return 0.0;}
  
      f([x](int i) -&gt; double    //[x] does not work
      {return 0.0;});
  }
  </code></pre>
  
  <p>which gives the error:</p>
  
  <pre><code>error: function "lambda [](double (*)(int))-&gt;double::operator()" cannot be called with the given argument list
          argument types are: (lambda [](int)-&gt;double)
          object type is: lambda [](double (*)(int))-&gt;double
  </code></pre>
  
  <p>would anyone have an idea as to how to fix this, or a way around it?
  I am using the intel compiler
  icpc (ICC) 13.1.2 with std=c++11</p>
  
  <p>Thanks</p>