Returning a pointer by reference
<p>I have seen some C++ that looks like this:</p>

<pre><code>const Foo*&amp; ptr = GetPointerToFoo();
</code></pre>

<p>Which seems to do the same job as:</p>

<pre><code>const Foo* ptr = GetPointerToFoo();
</code></pre>

<p>Or even:</p>

<pre><code>Foo* ptr = GetPointerToFoo();
</code></pre>

<p>What is the use of the <code>&amp;</code> in the first example? Does it pass the value returned by <code>GetPointerToFoo()</code> by reference? What would be the use of this? Is it just to make it run faster so that this pointer does not need to be copied? If so, it seems rather a complicated implementation for a very small increase in speed... Or are there other reasons to use the <code>&amp;</code> here?</p>