From 535636aeaebb7f29af5a36f79e7591d45e4124e0 Mon Sep 17 00:00:00 2001 From: SilverPlate3 <93097769+SilverPlate3@users.noreply.github.com> Date: Tue, 23 Jul 2024 11:17:47 +0300 Subject: [PATCH] Cpp depended if constexpr pointer.h Fix windows compile warning C4127 --- include/rapidjson/pointer.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/rapidjson/pointer.h b/include/rapidjson/pointer.h index 6f4ef3892..355929ede 100644 --- a/include/rapidjson/pointer.h +++ b/include/rapidjson/pointer.h @@ -28,6 +28,12 @@ RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated #endif +#if defined(RAPIDJSON_CPLUSPLUS) && RAPIDJSON_CPLUSPLUS >= 201703L +#define RAPIDJSON_IF_CONSTEXPR if constexpr +#else +#define RAPIDJSON_IF_CONSTEXPR if +#endif + RAPIDJSON_NAMESPACE_BEGIN static const SizeType kPointerInvalidIndex = ~SizeType(0); //!< Represents an invalid index in GenericPointer::Token @@ -291,7 +297,7 @@ class GenericPointer { SizeType length = static_cast(end - buffer); buffer[length] = '\0'; - if (sizeof(Ch) == 1) { + RAPIDJSON_IF_CONSTEXPR (sizeof(Ch) == 1) { Token token = { reinterpret_cast(buffer), length, index }; return Append(token, allocator); }