From ccac6403d99a997814ec3e2ca13e49f53d448b25 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Sat, 1 Nov 2025 17:28:17 -0400 Subject: [PATCH] fixing support for pre-C++17 --- include/simdjson/compiler_check.h | 5 +++++ include/simdjson/generic/numberparsing.h | 4 ++-- include/simdjson/internal/numberparsing_tables.h | 6 +++--- src/internal/numberparsing_tables.cpp | 4 ---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/simdjson/compiler_check.h b/include/simdjson/compiler_check.h index b045f3b05..72400a30a 100644 --- a/include/simdjson/compiler_check.h +++ b/include/simdjson/compiler_check.h @@ -13,6 +13,11 @@ #endif #endif +// C++ 26 +#if !defined(SIMDJSON_CPLUSPLUS26) && (SIMDJSON_CPLUSPLUS >= 202402L) // update when the standard is finalized +#define SIMDJSON_CPLUSPLUS26 1 +#endif + // C++ 23 #if !defined(SIMDJSON_CPLUSPLUS23) && (SIMDJSON_CPLUSPLUS >= 202302L) #define SIMDJSON_CPLUSPLUS23 1 diff --git a/include/simdjson/generic/numberparsing.h b/include/simdjson/generic/numberparsing.h index c769f813e..35d574157 100644 --- a/include/simdjson/generic/numberparsing.h +++ b/include/simdjson/generic/numberparsing.h @@ -167,7 +167,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative, // with a returned value of type value128 with a "low component" corresponding to the // 64-bit least significant bits of the product and with a "high component" corresponding // to the 64-bit most significant bits of the product. -#if SIMDJSON_CPLUSPLUS17 +#if SIMDJSON_CPLUSPLUS26 simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index]); #else simdjson::internal::value128 firstproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index]); @@ -205,7 +205,7 @@ simdjson_inline bool compute_float_64(int64_t power, uint64_t i, bool negative, // with a returned value of type value128 with a "low component" corresponding to the // 64-bit least significant bits of the product and with a "high component" corresponding // to the 64-bit most significant bits of the product. -#if SIMDJSON_CPLUSPLUS17 +#if SIMDJSON_CPLUSPLUS26 simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::powers_template<>::power_of_five_128[index + 1]); #else simdjson::internal::value128 secondproduct = full_multiplication(i, simdjson::internal::power_of_five_128[index + 1]); diff --git a/include/simdjson/internal/numberparsing_tables.h b/include/simdjson/internal/numberparsing_tables.h index 4e6c38ef3..0f0d6f897 100644 --- a/include/simdjson/internal/numberparsing_tables.h +++ b/include/simdjson/internal/numberparsing_tables.h @@ -53,7 +53,7 @@ extern SIMDJSON_DLLIMPORTEXPORT const double power_of_ten[]; // The mantissa is truncated to 128 bits, and // never rounded up. Uses about 10KB. // We use the template trick to allow inclusion in multiple translation units. -#if SIMDJSON_CPLUSPLUS17 +#if SIMDJSON_CPLUSPLUS26 template struct powers_template { constexpr static uint64_t power_of_five_128[651*2]= { 0xeef453d6923bd65a,0x113faa2906a13b3f, @@ -708,9 +708,9 @@ constexpr static uint64_t power_of_five_128[651*2]= { 0xe3d8f9e563a198e5,0x58180fddd97723a6, 0x8e679c2f5e44ff8f,0x570f09eaa7ea7648,}; }; -#else +#endif // SIMDJSON_CPLUSPLUS26 + extern SIMDJSON_DLLIMPORTEXPORT const uint64_t power_of_five_128[651*2]; -#endif } // namespace internal } // namespace simdjson diff --git a/src/internal/numberparsing_tables.cpp b/src/internal/numberparsing_tables.cpp index e0686d559..143b27506 100644 --- a/src/internal/numberparsing_tables.cpp +++ b/src/internal/numberparsing_tables.cpp @@ -20,9 +20,6 @@ SIMDJSON_DLLIMPORTEXPORT const double simdjson::internal::power_of_ten[] = { * exactly using the binary notation, only the powers of five * affect the binary significand. */ -#if SIMDJSON_CPLUSPLUS17 -// See header file. We use the template trick to allow inclusion in multiple translation units. -#else // The truncated powers of five from 5^-342 all the way to 5^308 // The mantissa is truncated to 128 bits, and // never rounded up. Uses about 10KB. @@ -678,7 +675,6 @@ SIMDJSON_DLLIMPORTEXPORT const uint64_t simdjson::internal::power_of_five_128[]= 0xb6472e511c81471d,0xe0133fe4adf8e952, 0xe3d8f9e563a198e5,0x58180fddd97723a6, 0x8e679c2f5e44ff8f,0x570f09eaa7ea7648,}; -#endif // SIMDJSON_CPLUSPLUS17 #endif // SIMDJSON_SRC_NUMBERPARSING_TABLES_CPP \ No newline at end of file