Is it really the best practice to prefer C++ references to pointers in all situations?
<p><a href="http://www.parashift.com/c++-faq-lite/references.html#faq-8.6">C++ FAQ</a> says:</p>

<p><em><strong>“Use references when you can, and pointers when you have to.”</em></strong></p>

<p>I feel it’s not as easy as stated above. The reasons why references are generally better to pointers have been well discussed. So I would rather like to discuss special cases where references make sense but are highly unusual and just don’t feel right:</p>

<p>To me the most obvious case is their usage in <strong>general data structures</strong> like a tree or linked-list. Their interfaces could be certainly implemented using references and feel safer, but I haven’t seen a single implementation that would take advantage of  references e.g.:</p>

<pre><code>Node *parent = n.parent(); // parent might be unset -&gt; pointer
Node &amp;child = n.child(5); // child is always valid -&gt; reference
</code></pre>

<p>Although it might seem attractive, it leads to code like this:</p>

<pre><code>if(parent == &amp;child) ... //  weird, unusual at least?
</code></pre>

<p>I’m wondering, is this what stands for pure C++?</p>

<p>Each time I’ve tried to blindly use references wherever it’s possible, I’ve encountered all kinds of similar <strong>inconsistencies</strong> and ended up <strong>mixing pointers and references</strong> in various ugly ways.</p>

<p>To conclude, why the <strong>operator new</strong> doesn’t return a reference to a new instance instead of a pointer in the first place? (and throws in case of error):</p>

<pre><code>Node &amp;n = new Node;
delete &amp;n;
</code></pre>

<p>It’s an absurd example, but isn’t that what would be “pure C++”?</p>
