title: Using r-value references outside of constructors/assignment operators
body: <p>I'm currently learning about R-value references by reading tutorials. Many tutorials mention move constructors/assignment operators as the main use case of R-value references. So I'm wondering whether/how they should be used outside of the &quot;Rule of 5&quot;.</p>
  <p>Say I have a function</p>
  <pre><code>std::string foo();
  </code></pre>
  <p>which returns a potentially large string, and want to pass its output to</p>
  <pre><code>int bar (const std::string&amp; s);
  </code></pre>
  <p>.</p>
  <p>Consider 3 options of doing this.</p>
  <p>1.</p>
  <pre><code>const std::string my_string = foo();
  const int x = bar(my_string);
  </code></pre>
  <ol start="2">
  <li></li>
  </ol>
  <pre><code>std::string&amp;&amp; my_string = foo();
  const int x = bar(my_string);
  </code></pre>
  <ol start="3">
  <li></li>
  </ol>
  <pre><code>const int x = bar(foo());
  </code></pre>
  <p>My understanding is that 2. and 3. are essentially the same (in both cases, there's never an l-value holding <code>my_string</code>), but 2. may be more readable (the string can be given a name, and the statement can be broken up into multiple lines). None of the 3 options does any unnecessary copies. The difference between 2. and 1. is that in 1., <code>my_string</code> will live till it goes out of scope, while in 2., I tell the compiler that I don't need <code>my_string</code> any more after passing it to <code>bar</code>, allowing to free its memory earlier.</p>
  <p>Is the above correct? If so, is 2. the best option to use here?</p>