Fix -Wctad-maybe-unsupported in counted_iterator test

std::counted_iterator's constructor deduction guide isn't guaranteed
to be intentionally supported by every standard library, so clang's
-Weverything flags implicit CTAD on it. Use an explicit template
argument instead, matching how the rest of the test suite avoids CTAD
on standard library types under strict warning flags.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann
2026-07-11 18:47:33 +02:00
parent 424a88b4fb
commit 55a12ee212
+4 -3
View File
@@ -216,15 +216,16 @@ TEST_CASE("Parse with heterogeneous iterator and sentinel types")
// JSON_HAS_CPP_20 (do not remove; see note at top of file)
TEST_CASE("Parse with std::counted_iterator and std::default_sentinel_t")
{
using iterator_type = std::string::const_iterator;
const std::string json_str = R"({"key":"value","array":[1,2,3]})";
const auto len = static_cast<std::iter_difference_t<std::string::const_iterator>>(json_str.size());
const auto len = static_cast<std::iter_difference_t<iterator_type>>(json_str.size());
std::counted_iterator first(json_str.begin(), len);
std::counted_iterator<iterator_type> first(json_str.begin(), len);
const json j = json::parse(first, std::default_sentinel);
CHECK(j["key"] == "value");
CHECK(j["array"].size() == 3);
std::counted_iterator first2(json_str.begin(), len);
std::counted_iterator<iterator_type> first2(json_str.begin(), len);
CHECK(json::accept(first2, std::default_sentinel));
}
#endif