title: No matching function error when passing lambda function as argument
body: <p>I have a list of numbers.</p>
  
  <p>I am trying to filter the list and only keep the positive numbers.</p>
  
  <p>I am trying to do it by passing a lambda as an argument.</p>
  
  <p>I wonder why I get function mismatch error.</p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;algorithm&gt;
  #include &lt;functional&gt;
  
  template&lt;typename T&gt;
  std::vector&lt;T&gt; keep(
          const std::vector&lt;T&gt; &amp;original,
          std::function&lt;bool(const T&amp;)&gt; useful)
  {
      std::vector&lt;T&gt; out;
      for(T item:original)
      {
          if(useful(item))
              out.push_back(item);
      }
      return out;
  }
  
  int main()
  {
      std::vector&lt;int&gt; a={4,6,2,-5,3,-8,13,-11,27};
      a=keep(a,[](const int&amp; x)-&gt;bool{return x&gt;0;});
      for(int y:a)
      {
          std::cout&lt;&lt;y&lt;&lt;std::endl;
      }
      return 0;
  }
  </code></pre>
  
  <p>And this is the error message:</p>
  
  <pre><code>error: no matching function for call to ‘keep(std::vector&lt;int&gt;&amp;, main()::&lt;lambda(const int&amp;)&gt;)’
       a=keep(a,[](const int&amp; x)-&gt;bool{return x&gt;0;});
                                                   ^
  </code></pre>