title: Decay types before passing to std::result_of
body: <p>As shown on this page <a href="http://en.cppreference.com/w/cpp/thread/async">http://en.cppreference.com/w/cpp/thread/async</a>, one of the signature of <code>std::async</code> in C++14 has been changed from the C++11 version</p>
  
  <pre><code>template&lt; class Function, class... Args&gt;
  std::future&lt;typename std::result_of&lt;Function(Args...)&gt;::type&gt;
      async( Function&amp;&amp; f, Args&amp;&amp;... args );
  </code></pre>
  
  <p>to</p>
  
  <pre><code>template&lt; class Function, class... Args&gt;
  std::future&lt;std::result_of_t&lt;std::decay_t&lt;Function&gt;(std::decay_t&lt;Args&gt;...)&gt;&gt;
      async( Function&amp;&amp; f, Args&amp;&amp;... args );
  </code></pre>
  
  <p>The changes are the <code>std::decay_t</code>s (which remove references and cv-qualifiers and decay arrays/functions into pointers) applied on function and argument types before they are passed to <code>std::result_of</code>. I can't quite see why the decay is useful. For example, for a function type <code>Fn</code> (maybe a type alias of a closure class), passing <code>Fn</code>, <code>Fn&amp;&amp;</code>, <code>const Fn&amp;</code> etc. all seem to yield the same result. </p>
  
  <p>Can someone give me a concrete example where the decay is useful?</p>
  
  <p><strong>UPDATE:</strong> As an example, this code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;type_traits&gt;
  
  int main()
  {
      auto fn = [](auto x) -&gt; int { return x + 1; };
  
      using Fn = decltype(fn);
      using FnRef = Fn&amp;;
      using FnCRef = const Fn&amp;;
      using FnRRef = Fn&amp;&amp;;
  
      std::cout &lt;&lt; std::boolalpha
                &lt;&lt; std::is_same&lt;int, std::result_of_t&lt;Fn(int)&gt;&gt;::value &lt;&lt; '\n'
                &lt;&lt; std::is_same&lt;int, std::result_of_t&lt;FnRef(int)&gt;&gt;::value &lt;&lt; '\n'
                &lt;&lt; std::is_same&lt;int, std::result_of_t&lt;FnCRef(int)&gt;&gt;::value &lt;&lt; '\n'
                &lt;&lt; std::is_same&lt;int, std::result_of_t&lt;FnRRef(int)&gt;&gt;::value &lt;&lt; '\n';
  
      return 0;
  }
  </code></pre>
  
  <p>will print out four <code>true</code>s.</p>