On Wed, Apr 11, 2018 at 8:40 AM, Even Rouault <even.roua...@spatialys.com> wrote:
> On mercredi 11 avril 2018 05:10:53 CEST Kurt Schwehr wrote: > > The auto&& is really confusing. > > A experimentally working alternative with miminal use of '&' is > > for( auto poLayer: poDS->GetLayers() ) <-- this is a plain OGRLayer* > { > 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 > { > 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) > > Does that look better ? > > In all those above cases, the auto could also be const'ified, so the > stricter typing would be > > for( const auto poLayer: poDS->GetLayers() ) > { > for( const auto& poFeature: *poLayer ) > { > for( const auto& oField: *poFeature ) > Should we put that instead ? > 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. -- Andrew Bell andrew.bell...@gmail.com
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev