[gdal-dev] VS 2013 and list initialization

Even Rouault even.rouault at spatialys.com
Sat Dec 16 11:45:41 PST 2017


Hi,

While writing a new driver, I've experimented a bit with C++11 default non-static data
member initialization.

Unfortunately the following

class C
{
	double m_adfGeotransform[6]{0,1,0,0,0,1}; // breaks VS 2013
};

which works with conformant C+11 compilers breaks on VS 2013 with

error C2797: 
list initialization inside member initializer list or non-static data member initializer is not implemented

Similary, double m_adfGeotransform[6] = {0,1,0,0,0,1} also breaks.

This is discussed in
https://stackoverflow.com/questions/27741521/error-c2797-list-initialization-inside-member-initializer-list
https://blogs.msdn.microsoft.com/vcblog/2014/08/19/the-future-of-non-static-data-member-initialization/
The issue has been solved in VS2015

A workaround is to use std::array and non-static data member initialization with equal initializer and explicit type
in front of initialized values

class C 
{
	std::array<double,6> m_adfGeotransform = std::array<double,6>{{0,1,0,0,0,1}}; // OK VS 2013
};

(For the same reason as above, direct initialization
     std::array<double,6> m_adfGeotransform{{0,1,0,0,0,1}}; // breaks VS 2013
)

Given this and other issues found, we might revisit at some point supporting VS2013. Would
still be good to try to have it for GDAL 2.3, but we can perhaps drop it afterwards.


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/20171216/3568859e/attachment.html>


More information about the gdal-dev mailing list