From 75efea25b2b805da489558d6d8bb854e37c4c744 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 19 Oct 2026 22:06:50 +0200 Subject: [PATCH] Skip the deleted-overload checks of json_view on MSVC 2015 MSVC 2015 does not treat selecting a deleted function in decltype as a substitution failure, so is_detected reports the deleted parse/parse_copy/accept/read(ptr, len) overloads as callable and the static_asserts in "integer arguments do not compile" fail (AppVeyor VS2015 jobs). Calling them still fails to compile there. Guard the negative checks as unit-delete_deprecated_functions.cpp does. Signed-off-by: Niels Lohmann --- tests/src/unit-json_view.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/src/unit-json_view.cpp b/tests/src/unit-json_view.cpp index 6e91200b4..ea3be303a 100644 --- a/tests/src/unit-json_view.cpp +++ b/tests/src/unit-json_view.cpp @@ -511,27 +511,31 @@ TEST_CASE("json_view") { using nlohmann::detail::is_detected; - // a length is not a flag: parse(ptr, len) would convert len to - // allow_exceptions and read ptr as a C string, which need not end static_assert(is_detected::value, "parse(ptr, bool) is valid"); static_assert(is_detected::value, "parse(ptr, bool, bool, bool) is valid"); static_assert(is_detected::value, "parse(first, last) is valid"); static_assert(is_detected::value, "parse(first, last, bool) is valid"); + static_assert(is_detected::value, "parse_copy(ptr, bool) is valid"); + static_assert(is_detected::value, "accept(ptr, bool) is valid"); + static_assert(is_detected::value, "read(ptr, bool) is valid"); + + // a length is not a flag: parse(ptr, len) would convert len to + // allow_exceptions and read ptr as a C string, which need not end + // + // MSVC 2015 does not treat selecting a deleted function in decltype as + // a substitution failure, so it detects the deleted overloads as + // callable; calling them still fails to compile +#if !(defined(_MSC_VER) && _MSC_VER < 1910) static_assert(!is_detected::value, "parse(ptr, len) must not compile"); static_assert(!is_detected::value, "parse(ptr, int) must not compile"); static_assert(!is_detected::value, "parse(ptr, char) must not compile"); static_assert(!is_detected::value, "parse(ptr, len, bool) must not compile"); static_assert(!is_detected::value, "parse(string, len) must not compile"); static_assert(!is_detected&, std::size_t>::value, "parse(vector, len) must not compile"); - - static_assert(is_detected::value, "parse_copy(ptr, bool) is valid"); static_assert(!is_detected::value, "parse_copy(ptr, len) must not compile"); - - static_assert(is_detected::value, "accept(ptr, bool) is valid"); static_assert(!is_detected::value, "accept(ptr, len) must not compile"); - - static_assert(is_detected::value, "read(ptr, bool) is valid"); static_assert(!is_detected::value, "read(ptr, len) must not compile"); +#endif // json_view has no conversion to bool: unlike basic_json's, it would // mean "exists", not "is not null"; use is_discarded()