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 ?

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to