title: Forward a move reference through a function, without writing the function twice
body: <p>Recently I often encountered the problem, that I had to write a function which takes an input as a const reference. But at some point this function (usually a constructor) calls another function which could use the input as a move reference. For that reason I usually created a copy of the function to allow const reference and move reference, i.e.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  class A {};
  
  void foo(const A&amp;  a) { std::cout &lt;&lt; "Reference" &lt;&lt; std::endl; }
  
  void foo(      A&amp;&amp; a) { std::cout &lt;&lt; "Move" &lt;&lt; std::endl; }
  
  void bar(const A&amp; a) {
      //Other things, which treat "a" as a const reference
      foo(std::move(a));
  }
  
  void bar(A&amp;&amp; a) {
      //Other things, which treat "a" as a const reference
      foo(std::move(a));
  }
  
  int main() {
      A a;
      bar(a);
      bar(A());
  }
  </code></pre>
  
  <p>However it is obviously pretty ugly to copy <code>bar</code> two times with the only difference being the signature and the <code>std::move</code>. One alternative I know would be to make <code>bar</code> a tempalte function and to use <code>std::forward</code>, but I don't want to do that because it would allow any parameter type to be passed to <code>bar</code> (especially since in my real application bar is an implicit constructor). </p>
  
  <p>So my question is: Is there any other way to forward a move reference through a function without writing it twice?</p>