From eaee8751788b1aa72711743c89ba7564a1411867 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 2 Nov 2026 19:12:26 +0100 Subject: [PATCH] json_view: no constant operand in the number dispatch (MSVC C4127) The `!negative ||` that #6006 added to the digit test of the number scan has a constant left operand in the template (negative is a template argument), so MSVC reports C4127 under /WX in builder.hpp(1177). Restore the plain test; the branch behaves the same. Signed-off-by: Niels Lohmann --- include/nlohmann/detail/view/builder.hpp | 3 +-- single_include/nlohmann/json_view.hpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/include/nlohmann/detail/view/builder.hpp b/include/nlohmann/detail/view/builder.hpp index 283cae075..938d6d73b 100644 --- a/include/nlohmann/detail/view/builder.hpp +++ b/include/nlohmann/detail/view/builder.hpp @@ -1174,9 +1174,8 @@ indent_done: { ++p; } - else if (!negative || NLOHMANN_VIEW_LIKELY(cur() >= '1' && cur() <= '9')) + else if (NLOHMANN_VIEW_LIKELY(cur() >= '1' && cur() <= '9')) { - // (without a sign, the dispatch saw a digit) p = skip_digits(p + 1, e); } else diff --git a/single_include/nlohmann/json_view.hpp b/single_include/nlohmann/json_view.hpp index 1c6cd6cef..405e272a6 100644 --- a/single_include/nlohmann/json_view.hpp +++ b/single_include/nlohmann/json_view.hpp @@ -2479,9 +2479,8 @@ indent_done: { ++p; } - else if (!negative || NLOHMANN_VIEW_LIKELY(cur() >= '1' && cur() <= '9')) + else if (NLOHMANN_VIEW_LIKELY(cur() >= '1' && cur() <= '9')) { - // (without a sign, the dispatch saw a digit) p = skip_digits(p + 1, e); } else