[gdal-dev] Initializing vectors
Even Rouault
even.rouault at spatialys.com
Tue May 15 14:19:02 PDT 2018
On mardi 15 mai 2018 14:09:45 CEST Kurt Schwehr wrote:
> Hi Even,
>
> Trying to get caught up going through patches. A comment for this one:
>
> https://github.com/OSGeo/gdal/blob/f7c27a807b27cf74cf4666ffe3df4d64cc3f47b3/
> gdal/frmts/gtiff/geotiff.cpp
>
> You can size and initialize a vector in the constructor. With this code:
>
> std::vector<bool> abRequireNewOverview;
> abRequireNewOverview.resize(nOverviews);
> for( int i = 0; i < nOverviews && eErr == CE_None; ++i )
> {
> abRequireNewOverview[i] = true;
>
> The vector can be setup all at one go...
>
> std::vector<bool> abRequireNewOverview(nOverviews, true);
Kurt,
Yeah, I know this kind of initialization exists. My issue is that I never remember if this is count,
value or value, count and when this is a vector<int> (and presumably vector<bool>), the
compiler cannot yell at you if you got it wrong... I miss named parameters there...
That said I've fixed the above instance and similar ones as you suggest.
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20180515/2a86fe9c/attachment.html>
More information about the gdal-dev
mailing list