Cpp depended if constexpr pointer.h

Fix windows compile warning C4127
This commit is contained in:
SilverPlate3 2024-07-23 11:17:47 +03:00 committed by Milo Yip
parent ebd87cb468
commit 535636aeae

View File

@ -28,6 +28,12 @@ RAPIDJSON_DIAG_PUSH
RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated
#endif #endif
#if defined(RAPIDJSON_CPLUSPLUS) && RAPIDJSON_CPLUSPLUS >= 201703L
#define RAPIDJSON_IF_CONSTEXPR if constexpr
#else
#define RAPIDJSON_IF_CONSTEXPR if
#endif
RAPIDJSON_NAMESPACE_BEGIN RAPIDJSON_NAMESPACE_BEGIN
static const SizeType kPointerInvalidIndex = ~SizeType(0); //!< Represents an invalid index in GenericPointer::Token static const SizeType kPointerInvalidIndex = ~SizeType(0); //!< Represents an invalid index in GenericPointer::Token
@ -291,7 +297,7 @@ public:
SizeType length = static_cast<SizeType>(end - buffer); SizeType length = static_cast<SizeType>(end - buffer);
buffer[length] = '\0'; buffer[length] = '\0';
if (sizeof(Ch) == 1) { RAPIDJSON_IF_CONSTEXPR (sizeof(Ch) == 1) {
Token token = { reinterpret_cast<Ch*>(buffer), length, index }; Token token = { reinterpret_cast<Ch*>(buffer), length, index };
return Append(token, allocator); return Append(token, allocator);
} }