title: When should I std::forward a function call?
body: <p>A code snippet I saw in <em>Effective Modern C++</em> has a clever implementation of the <a href="https://stackoverflow.com/a/21995693/2567683">instrumentation rationale</a> to create a <strong>function timer</strong> : </p>
  
  <pre><code>auto timeFuncInvocation = 
      [](auto&amp;&amp; func, auto&amp;&amp;... params)
      {
          start timer; 
          std::forward&lt;decltype(func)&gt;(func)(
              std::forward&lt;decltype(params)&gt;(params)...); 
          stop timer and record elapsed time; 
      };
  </code></pre>
  
  <p>My question is about <code>std::forward&lt;decltype(func)&gt;(func)(...</code></p>
  
  <ul>
  <li>To my understanding, we are actually <em>casting</em> the function to its <em>original</em> type, but <strong>why is this needed?</strong> It looks like a simple call would do the trick. </li>
  <li>Are there any other cases where we use perfect forwarding to make a function call ? </li>
  </ul>
  
  <hr>
  
  <p><sup>This looks like a good use case for <a href="https://stackoverflow.com/q/31195156/2567683">the use of familiar template syntax in lambda expressions</a> in case we wanted to make the timer type a compile time constant.</sup></p>