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 <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann
2026-09-29 09:34:11 +02:00
parent 7917cfa0f4
commit 58ac756134

View File

@@ -12,7 +12,7 @@
#include <algorithm> // max
#include <array> // array
#include <cstddef> // size_t, ptrdiff_t
#include <cstdint> // uint8_t, uint16_t, uint32_t, uint64_t
#include <cstdint> // int64_t, uint8_t, uint16_t, uint32_t, uint64_t
#include <cstring> // memcmp, memcpy
#include <limits> // numeric_limits
#include <string> // string
@@ -890,7 +890,7 @@ indent_done:
frac_digits = static_cast<std::size_t>(p - f0);
is_float = true;
}
long exponent = 0;
std::int64_t exponent = 0;
if (p != e && (*p | 0x20) == 'e')
{
++p;
@@ -944,7 +944,7 @@ indent_done:
}
// parse() rejects floats that overflow; only numbers whose magnitude
// could reach 1e308 need the conversion
if (NLOHMANN_VIEW_UNLIKELY(static_cast<long>(int_digits) + exponent > 300 && kind == value_t::number_float))
if (NLOHMANN_VIEW_UNLIKELY(static_cast<std::int64_t>(int_digits) + exponent > 300 && kind == value_t::number_float))
{
if (builder::float_overflows(s, p))
{