title: Default template argument for function ignored
body: <pre><code>template &lt; class A, class B, class R = A &gt;
  void addMultiplyOperation( std::function&lt; R ( const A&amp;, const B&amp; ) &gt; func )
  {
      ...
  }
  
  addMultiplyOperation&lt; float, int &gt;( []( float a, int b ) { return a * b; } );
  </code></pre>
  
  <p>This gives the compiler error:</p>
  
  <pre><code>In function 'int main(int, char**)':
  error: no matching function for call to 'addMultiplyOperation(main(int, char**)::__lambda1)'
  addMultiplyOperation&lt; float, int &gt;( []( float a, int b ) { return a * b; } );
                                                                             ^
  note:   candidate is:
  note:   template&lt;class A, class B, class R&gt; void addMultiplyOperation(std::function&lt;R(const A&amp;, const B&amp;)&gt;)
  void addMultiplyOperation( std::function&lt; R ( const A&amp;, const B&amp; ) &gt; func )
       ^
  note:   template argument deduction/substitution failed:
  note:   'main(int, char**)::__lambda1' is not derived from 'std::function&lt;R(const float&amp;, const int&amp;)&gt;'
   addMultiplyOperation&lt; float, int &gt;( []( float a, int b ) { return a * b; } );
                                                                              ^
  </code></pre>
  
  <p>Despite having the <code>R</code> template argument default initialised to <code>A</code>, I <em>have</em> to provide the third argument in order for this to compile.  Is there something else I have to do in order to use default template arguments?</p>
  
  <p>I'm using g++ v4.8.1.</p>