From 402af742c0d23f72b151b1ae637e26f45c4046ab Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 27 Oct 2026 18:01:12 +0100 Subject: [PATCH] Fix the VS2015 build of unit-json_view_edit_values.cpp MSVC 2015 treats two function templates that differ only in a decltype return type as a redefinition (C2995), which breaks all three Visual Studio 2015 jobs on AppVeyor. Overload on the view's mode in the parameter type instead; template argument deduction ignores the read-only-to-editable conversion, so each view still selects the overload of its own mode. Signed-off-by: Niels Lohmann --- tests/src/unit-json_view_edit_values.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/src/unit-json_view_edit_values.cpp b/tests/src/unit-json_view_edit_values.cpp index 39db8d0ba..881d957f8 100644 --- a/tests/src/unit-json_view_edit_values.cpp +++ b/tests/src/unit-json_view_edit_values.cpp @@ -54,14 +54,18 @@ int accepts_any(nlohmann::basic_json_view /*unused*/) return Mode == nlohmann::view_mode::editable ? 3 : 4; } -template -auto overload(View v) -> decltype(accepts_editable(v)) +// overloads that differ only in the mode; deduction ignores the conversion from +// read-only to editable views, so each view picks the overload of its own mode +// (two templates that differ only in a decltype return type are a redefinition +// for MSVC 2015) +template +int overload(nlohmann::basic_json_view v) { return accepts_editable(v); } -template -auto overload(View v) -> decltype(accepts_read_only(v)) +template +int overload(nlohmann::basic_json_view v) { return accepts_read_only(v); }