This commit is contained in:
Niels Lohmann 2025-02-04 11:19:30 +00:00 committed by GitHub
commit 34c317f6b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -42,6 +42,11 @@ using ordered_json = nlohmann::ordered_json;
#endif
#endif
// for #4440
#if JSON_HAS_RANGES == 1
#include <ranges>
#endif
// NLOHMANN_JSON_SERIALIZE_ENUM uses a static std::pair
DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
DOCTEST_CLANG_SUPPRESS_WARNING("-Wexit-time-destructors")
@ -1004,6 +1009,19 @@ TEST_CASE("regression tests 2")
CHECK(p.x == 1);
CHECK(p.y == 2);
}
#if JSON_HAS_RANGES == 1
SECTION("issue 4440")
{
auto noOpFilter = std::views::filter([](auto&&) noexcept
{
return true;
});
json j = {1, 2, 3};
auto filtered = j | noOpFilter;
CHECK(*filtered.begin() == 1);
}
#endif
}
DOCTEST_CLANG_SUPPRESS_WARNING_POP