title: Why do we need to explicitly call std::move on a reference rvalue function parameter?
body: <p>One thing has been bugging me for quite a while now. When passing a reference rvalue to a function parameter, I need to forward it explicitly when passing it to another function, otherwise the reference rvalue is lost.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>void foo(const string&amp;);
  void foo(string&amp;&amp;);
  
  void bar1(string&amp;&amp; x) { foo(std::move(x)); } // Calls foo(string&amp;&amp;)
  void bar2(string&amp;&amp; x) { foo(std::forward&lt;string&gt;(x)); } // Calls foo(string&amp;&amp;)
  void bar3(string&amp;&amp; x) { foo(x); } // Calls foo(const string&amp;), why not foo(string&amp;&amp;)?
  </code></pre>
  
  <p><a href="http://ideone.com/9fVq2b" rel="nofollow noreferrer">» Sample program «</a></p>
  
  <p>I have no doubt about how and why <code>bar1</code> and <code>bar2</code> work.</p>
  
  <p>What bugs me in <code>bar3</code> is that its parameter is of type <code>string&amp;&amp;</code>, so when I call <code>foo(x)</code> I would expect the compiler to set a higher priority for a function with a signature that matches exactly the parameter, i.e. <code>foo(string&amp;&amp;)</code> instead of <code>foo(const string&amp;)</code>.</p>
  
  <p>I’ve read <a href="https://stackoverflow.com/questions/37078582/why-exactly-is-stdmove-needed-on-a-function-parameter-which-is-already-an-rval">this topic</a> (which really looks like my problem) and <a href="https://stackoverflow.com/questions/14351669/rvalue-reference-why-arent-rvalues-implicitly-moved">this one</a> (which is supposed to be a duplicate, except it’s not) but the answers weren’t very helpful.</p>
  
  <p>What am I missing?</p>