<p>E.g.</p>

<p>What's best out of these:</p>

<pre><code>std::string f() {} 
</code></pre>

<p>or </p>

<pre><code>const std::string&amp; f() {}
</code></pre>

If you return a reference to a variable that is local to the function then you're going to end up with issues (depending on the compiler and its settings).
If you return a reference to an instance that's still in scope when the function returns then it will be faster, as no copy of the string is being created.
So the latter is more efficient (technically) but may not function as expected depending on what you return a reference to.