r-value parameters in a function
<p>I was wondering about a c++ behaviour when an r-value is passed among functions.</p>

<p>Look at this simple code:</p>

<pre><code>#include &lt;string&gt;

void foo(std::string&amp;&amp; str) {
  // Accept a rvalue of str
}

void bar(std::string&amp;&amp; str) {
  // foo(str);          // Does not compile. Compiler says cannot bind lvalue into rvalue.
  foo(std::move(str));  // It feels like a re-casting into a r-value?
}

int main(int argc, char *argv[]) {
  bar(std::string("c++_rvalue"));
  return 0;
}
</code></pre>

<p>I know when I'm inside <code>bar</code> function I need to use <code>move</code> function in order to invoke <code>foo</code> function. My question now is why?</p>

<p>When I'm inside the <code>bar</code> function the variable <code>str</code> should already be an <em>r-value</em>, but the compiler acts like it is a <em>l-value</em>.</p>

<p>Can somebody quote some reference to the standard about this behaviour?
Thanks!</p>