<div dir="ltr">On Fri, Jan 3, 2014 at 1:11 PM, Alexey Proskuryakov <<a href="mailto:ap@webkit.org">ap@webkit.org</a>> wrote:<br>>> auto sourceDescendants = descendantsOfType<HTMLSourceElement >(*this));<br>
<div>> So do we need auto or auto& here? I would know how to answer this question immediately if it was an explicit type, but I don't know how to answer it with auto in this particular case.<br>> [...]</div>
<div>> One shouldn't need even basic familiarity with style system to see whether code leaks, introduces refcount thrashing, or copies too much. Using auto tends to make such mistakes much more opaque.<br><br>How about preserving not only the ptrs and refs, but also the CV-qualifiers, when applicable?<br>
<div><br></div></div><div>Example 1:</div><div>auto* cache = new Cache; // right</div><div>auto cache = new Cache; // wrong, should be auto*</div><div><div>Cache* cache = new Cache; // wrong, should be auto*</div></div><div>
<br></div><div>Example 2:</div><div>const ClipboardFormatMap& formatMap = getClipboardMap(); // right<br></div><div>const auto& formatMap = getClipboardMap(); // also right</div><div>auto& formatMap = getClipboardMap(); // wrong, missing const</div>
<div>auto formatMap = getClipboardMap(); // wrong, missing const and &</div><div><br></div><div>Sincerely,</div><div>Cosmin</div></div>