Skip to content

Commit

Permalink
Cpp depended if constexpr pointer.h
Browse files Browse the repository at this point in the history
Fix windows compile warning C4127
  • Loading branch information
SilverPlate3 authored and miloyip committed Dec 10, 2024
1 parent ebd87cb commit 535636a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion include/rapidjson/pointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -291,7 +297,7 @@ class GenericPointer {
SizeType length = static_cast<SizeType>(end - buffer);
buffer[length] = '\0';

if (sizeof(Ch) == 1) {
RAPIDJSON_IF_CONSTEXPR (sizeof(Ch) == 1) {
Token token = { reinterpret_cast<Ch*>(buffer), length, index };
return Append(token, allocator);
}
Expand Down

0 comments on commit 535636a

Please sign in to comment.