<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><div class="">My take-away from this discussion so far is that there is actually very little consensus on usage of auto, which means there’s probably very little room for actual style guideline rules.<div class=""><br class=""></div><div class="">I think there are two very limited rules that are probably not objectionable to anybody.</div><div class=""><br class=""></div><div class="">1 - If you are using auto for a raw pointer type, you should use auto*</div><div class="">2 - If you are using auto in a range-based for loop for values that aren’t pointers, you should use (const) auto&amp;</div></div></blockquote><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">In some cases you need a copy for the code to be correct. I understand why &amp; is often better for performance but there is a significant and dangerous behavioral difference.</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">I agree with encouraging people to use auto&amp; because it's usually ok, but I disagree with mandating it because it's sometimes wrong.&nbsp;</div></div></blockquote><div><br class=""></div>Seems like we could still have a style guideline in favor of these styles.</div><div><br class=""></div><div>Style guidelines are always recommendations, which are of course not followed if they produce incorrect code. For example, it is S_OK to violate our camel case guidelines when interfacing with COM APIs.</div><div><br class=""></div><div>I think Darin would also suggest:</div><div><br class=""></div><div>1.5 - If you are using auto in a range-based for loop for values that are scalars, you should use auto.</div><div><br class=""></div><div>Geoff</div></body></html>