[gdal-dev] [gdal-commits] r41044 - trunk/gdal/port

Even Rouault even.rouault at spatialys.com
Fri Dec 15 07:22:53 PST 2017


Kurt,

It doesn't look like constexpr is available in VS2013 (at least not in all sub-versions of it):
https://stackoverflow.com/questions/20264644/constexpr-not-compiling-in-vc2013

Personnally, I don't see it as a super needed feature that would justify dropping VS2013 
support. Especially in the below use cases where it doesn't bring anything more than const, 
except more characters to type/read. I'd bet any sane compiler in -O2 will compile the source 
to the same machine code in all those cases

Even

On vendredi 15 décembre 2017 07:04:23 CET you wrote:
> Author: goatbar
> Date: 2017-12-15 07:04:23 -0800 (Fri, 15 Dec 2017)
> New Revision: 41044
> 
> Modified:
>    trunk/gdal/port/cpl_conv.cpp
> Log:
> const -> constexpr for things known at compile time in cpl_conv.cpp
> 
> 
> 
> Modified: trunk/gdal/port/cpl_conv.cpp
> ===================================================================
> --- trunk/gdal/port/cpl_conv.cpp	2017-12-15 14:37:43 UTC (rev 41043)
> +++ trunk/gdal/port/cpl_conv.cpp	2017-12-15 15:04:23 UTC (rev 41044)
> @@ -340,8 +340,8 @@
>  /************************************************************************/
> 
>  // ASCII characters.
> -static const char knLF = 10;
> -static const char knCR = 13;
> +constexpr char knLF = 10;
> +constexpr char knCR = 13;
> 
>  /**
>   * Reads in at most one less than nBufferSize characters from the fp
> @@ -666,7 +666,7 @@
>  /*      the line.                                                       */
>  /* -------------------------------------------------------------------- */
>      char *pszRLBuffer = nullptr;
> -    const size_t nChunkSize = 40;
> +    constexpr size_t nChunkSize = 40;
>      char szChunk[nChunkSize] = {};
>      size_t nChunkBytesRead = 0;
>      int nBufLength = 0;
> @@ -1984,8 +1984,8 @@
>  /*                            CPLDMSToDec()                             */
>  /************************************************************************/
> 
> -static const char *sym = "NnEeSsWw";
> -static const double vm[] = { 1.0, 0.0166666666667, 0.00027777778 };
> +constexpr char sym[] = "NnEeSsWw";
> +constexpr double vm[] = { 1.0, 0.0166666666667, 0.00027777778 };
> 
>  /** CPLDMSToDec */
>  double CPLDMSToDec( const char *is )
> @@ -2605,7 +2605,7 @@
>  /* -------------------------------------------------------------------- */
>  /*      Prepare buffer.                                                 */
>  /* -------------------------------------------------------------------- */
> -    const size_t nBufferSize = 1024 * 1024;
> +    constexpr size_t nBufferSize = 1024 * 1024;
>      GByte *pabyBuffer = static_cast<GByte
> *>(VSI_MALLOC_VERBOSE(nBufferSize)); if( pabyBuffer == nullptr )
>      {
> 
> _______________________________________________
> gdal-commits mailing list
> gdal-commits at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-commits


-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20171215/c00233b5/attachment.html>


More information about the gdal-dev mailing list