<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 11, 2018 at 8:40 AM, Even Rouault <span dir="ltr"><<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On mercredi 11 avril 2018 05:10:53 CEST Kurt Schwehr wrote:<br>
> The auto&& is really confusing.<br>
<br>
A experimentally working alternative with miminal use of '&' is<br>
<br>
for( auto poLayer: poDS->GetLayers() ) <-- this is a plain OGRLayer*<br>
{<br>
for( auto& poFeature: *poLayer ) <-- this is a unique_ptr<OGRFeature> so needs to be obtained by reference (otherwise compiler complains about use of deleted function unique_ptr(const unique_ptr&) = delete<br>
{<br>
for( auto& oField: *poFeature ) <-- this is a OGRFeature::FieldValue object that has no copy constructor (intended, we don't want user to be able to instanciate standalone FieldValue)<br>
<br>
Does that look better ?<br>
<br>
In all those above cases, the auto could also be const'ified, so the stricter typing would be<br>
<br>
for( const auto poLayer: poDS->GetLayers() )<br>
{<br>
for( const auto& poFeature: *poLayer )<br>
{<br>
for( const auto& oField: *poFeature ) </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Should we put that instead ?<br></blockquote><div><br></div><div>I believe the universal reference (&&) has no purpose in this context. It will decay to a standard reference. So what you post is more clear.</div><div><br></div></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Andrew Bell<br><a href="mailto:andrew.bell.ia@gmail.com" target="_blank">andrew.bell.ia@gmail.com</a></div>
</div></div>