[gdal-dev] Use of std::unique_ptr and auto in new code

Kurt Schwehr schwehr at gmail.com
Tue Dec 12 17:27:47 PST 2017


+1 on the range based for

+1 on std::unique_ptr, but ... I think GDAL should stick to these:

- Do not do "using std::unique_ptr;"
- Do not exposed std::unique_ptr to any public interfaces (for the time
being)

On Tue, Dec 12, 2017 at 4:06 AM, Even Rouault <even.rouault at spatialys.com>
wrote:

> > 1. std::unique_ptr
>
> >
>
> [...]
>
> >
>
> > Hopefully this will help to reduce the incidence of memory leaks.
>
>
>
> +1, that's one of the benefits of C++11
>
> >
>
> > --
>
> >
>
> > 2. auto
>
> >
>
> > I'd like to not have to write
>
> >
>
> > for( std::vector<std::unique_ptr<OGRFeature>>::iterator oIt =
>
> > apoMyList.begin();
>
> >
>
> > and simply write
>
> >
>
> > for( auto oIt = apoMyList.begin();
>
>
>
> +1. You could even use range based loop
>
>
>
> for( auto& olt: apoMyList )
>
>
>
> (or auto const& depending on what you want to do with it)
>
>
>
> Even
>
>
>
> --
>
> Spatialys - Geospatial professional services
>
> http://www.spatialys.com
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>



-- 
--
http://schwehr.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20171212/d11fbe26/attachment.html>


More information about the gdal-dev mailing list