From 243ed0a6ff3a6ab960375c999a14c5253127eeb7 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 29 Sep 2026 09:34:11 +0200 Subject: [PATCH] Address the cpplint findings of the view's parser The exponent of the overflow check is an std::int64_t instead of a long (runtime/int). Signed-off-by: Niels Lohmann --- include/nlohmann/detail/view/builder.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/nlohmann/detail/view/builder.hpp b/include/nlohmann/detail/view/builder.hpp index 416aa823d..bf5bb33e0 100644 --- a/include/nlohmann/detail/view/builder.hpp +++ b/include/nlohmann/detail/view/builder.hpp @@ -12,7 +12,7 @@ #include // find, find_if, max #include // array #include // size_t, ptrdiff_t -#include // uint8_t, uint16_t, uint32_t, uint64_t +#include // int64_t, uint8_t, uint16_t, uint32_t, uint64_t #include // memcmp, memcpy #include // numeric_limits #include // string @@ -892,7 +892,7 @@ indent_done: frac_digits = static_cast(p - f0); is_float = true; } - long exponent = 0; + std::int64_t exponent = 0; if (p != e && (*p | 0x20) == 'e') { ++p; @@ -947,7 +947,7 @@ indent_done: // parse() rejects floats that overflow; only numbers whose magnitude // could reach the largest FloatType (1e308 for double, 1e38 for // float) need the conversion - if (NLOHMANN_VIEW_UNLIKELY(static_cast(int_digits) + exponent > std::numeric_limits::max_exponent10 - 8 && kind == value_t::number_float)) + if (NLOHMANN_VIEW_UNLIKELY(static_cast(int_digits) + exponent > std::numeric_limits::max_exponent10 - 8 && kind == value_t::number_float)) { if (builder::float_overflows(s, p)) {