title: C++ performance improvement by binding returned value to const reference
body: <p>Consider I have the following function:</p>
  
  <pre><code>std::string foo();
  </code></pre>
  
  <p>Is there an advantage of doing this:</p>
  
  <pre><code>const std::string&amp; ref = foo();
  </code></pre>
  
  <p>over this:</p>
  
  <pre><code>std::string val = foo();
  </code></pre>
  
  <p>Or is the compiler smart enough to do optimizations in the second case.</p>