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); }