title: Which type to declare to avoid copy and make sure returned value is moved
body: <p>Suppose that</p>
  
  <ul>
  <li>I have a function <code>A f()</code>;</li>
  <li>I want to initialize a local variable <code>a</code> to the return value of <code>f</code>;</li>
  <li>I don't want to rely on RVO;</li>
  </ul>
  
  <p>What is the best option (and why) to avoid the return value of <code>f</code> being copied when</p>
  
  <ol>
  <li><code>a</code> may have to be modified</li>
  <li>I know that <code>a</code> will not be modified</li>
  </ol>
  
  <p>Options:</p>
  
  <p>a) <code>A a = f();</code>
   b) <code>A&amp;&amp; a = f();</code>
   c) <code>const A&amp; = f();</code>
   d) <code>const A&amp;&amp; = f();</code></p>
  
  <hr>
  
  <p>EDIT:</p>
  
  <p>I would say:</p>
  
  <ol>
  <li>b) </li>
  <li>c)</li>
  </ol>
  
  <p>Because both use references and avoid an extra copy (which could be avoided by RVO as well, but that is not guaranteed). So how come I see option a) suggested most of the time?</p>
  
  <p>I guess the heart of the question is: I get that a) most likely has the same effect as c), so why not use c) instead of a), to make things explicit and independent on the compiler?</p>