title: When should I choose copy elision over passing argument by const reference?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/7592630/is-pass-by-value-a-reasonable-default-in-c11">Is pass-by-value a reasonable default in C++11?</a>  </p>
  </blockquote>
  
  
  
  <p>I'm reading <a href="http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/" rel="nofollow noreferrer">Want Speed? Pass by Value.</a> by Dave Abrahams about copy elision and RVO. And I'm wondering why do we need the copy elision?</p>
  
  <p>I have been told too many times that you should pass function arguments by const reference to avoid copying (nearly every c++ book I read told me about this).</p>
  
  <p>Suppose we have two functions:</p>
  
  <pre><code>int f1(const string &amp;s);
  int f2(string s);
  </code></pre>
  
  <p>If the actual argument is an rvalue, copying will be avoided in both functions. But if the actual argument is an lvalue, copying will only be avoided in f1, not in f2. So why do we need this feature?</p>