[gdal-dev] Starting a discussion on style and coding guidelines

Andrew Bell andrew.bell.ia at gmail.com
Fri May 6 14:47:19 PDT 2016


On Fri, May 6, 2016 at 3:55 PM, Kurt Schwehr <schwehr at gmail.com> wrote:

> I was not intending for C++11 to be a big part of the discussion as it is
> a much more complicated topic, but I do appreciate the discussion.  I
> picked the stack + memset -> std::vector(nSize, initialValue) to do first
> because I thought it was a simpler issue than most and we could use it to
> figure out how to go about these sorts of discussions.  It's not a show
> stoper, but it is a real need.
>
> At this point, I think it would be good if we could pause the C++11
> discussion for a bit and back up to the original question.
>
> I'd like to ask folks a couple of things:
>
> - If you could stack rank (all or some) the options assuming that C++14
> was available
> - Is your top pick far better than the rest or just a little better?
> - Are there any options that you think should not be used in GDAL?
> - Are there any reasons to be for or against any particular alternative
> that we need to call out?
>

Doing a heap-based array is simple.  You can pretty-much copy the
std::array code from the standard library and introduce the indirection you
require.  It's better than a vector for the reasons you already mentioned.
Something that looks and acts like an array is better than a vector because
it makes the use clear.  If you have C++ 11 you can simply wrap
std::array.  C++03 has value initialization for arrays: new int[10]();, so
that's another alternative.

-- 
Andrew Bell
andrew.bell.ia at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20160506/04a668fc/attachment.html>


More information about the gdal-dev mailing list