From 46bead6e134f2fe883086ba315dc687ef06210f8 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 28 Oct 2026 22:08:55 +0100 Subject: [PATCH] Fix the VS2015 build of unit-json_view_positions.cpp (#5957) VS 2015 does not accept std::string::npos in a constant expression (C2131), and the constant is only used at run time. Signed-off-by: Niels Lohmann --- tests/src/unit-json_view_positions.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/src/unit-json_view_positions.cpp b/tests/src/unit-json_view_positions.cpp index 857b0cb8f..08ea47a08 100644 --- a/tests/src/unit-json_view_positions.cpp +++ b/tests/src/unit-json_view_positions.cpp @@ -32,7 +32,8 @@ using nlohmann::json_editable_document; namespace { -constexpr std::size_t npos = std::string::npos; +// not constexpr: VS 2015 does not accept std::string::npos in a constant expression (C2131) +const std::size_t npos = std::string::npos; // whether every value of a has the source positions of the value of b at the // same place (a and b are equal; shallow test documents only)