title: No matching function std::forward with lambdas
body: <p>Consider the following code, inspired from Barry's answer to <a href="https://stackoverflow.com/a/42036525/882932">this</a> question:</p>
  
  <pre><code>// Include
  #include &lt;tuple&gt;
  #include &lt;utility&gt;
  #include &lt;iostream&gt;
  #include &lt;type_traits&gt;
  
  // Generic overload rank
  template &lt;std::size_t N&gt; 
  struct overload_rank 
  : overload_rank&lt;N - 1&gt; 
  {
  };
  
  // Default overload rank
  template &lt;&gt; 
  struct overload_rank&lt;0&gt; 
  {
  };
  
  // Prepend argument to function
  template &lt;std::size_t N, class F&gt;
  auto prepend_overload_rank(F&amp;&amp; f) {
      using rank = overload_rank&lt;N&gt;;
      return [f = std::forward&lt;F&gt;(f)](rank, auto&amp;&amp;... args) -&gt; decltype(auto) {
          return std::forward&lt;F&gt;(f)(std::forward&lt;decltype(args)&gt;(args)...); // here
      };
  }
  
  // Main
  int main(int argc, char* argv[])
  {
      auto f = [](int i){return i;};
      prepend_overload_rank&lt;5&gt;(f)(overload_rank&lt;5&gt;(), 1);
      return 0;
  }
  </code></pre>
  
  <p>It is not compiling because of line noted <code>here</code>, and I don't understand why:</p>
  
  <pre><code>With g++:
  error: no matching function for call to 'forward&lt;main(int, char**)::&lt;lambda(int)&gt;&amp;&gt;(const main(int, char**)::&lt;lambda(int)&gt;&amp;)'
  With clang:
  error: no matching function for call to 'forward'
  </code></pre>
  
  <p>Replacing </p>
  
  <pre><code>return std::forward&lt;F&gt;(f)(std::forward&lt;decltype(args)&gt;(args)...); 
  </code></pre>
  
  <p>by</p>
  
  <pre><code>return f(std::forward&lt;decltype(args)&gt;(args)...); 
  </code></pre>
  
  <p>apparently makes it work, but again, I don't understand why, and my goal is to achieve a perfect forwarding of the function.</p>