mirror of
https://github.com/nlohmann/json.git
synced 2026-07-11 21:15:10 +00:00
0e03ecee10
Extend the memcpy fast path in iterator_input_adapter to sized sentinels of a different type, not just same-type iterator pairs. std::counted_iterator paired with std::default_sentinel_t already satisfies std::contiguous_iterator and std::sized_sentinel_for, so std::ranges::distance (C++20) lets that combination reach the fast path too, instead of silently falling back to the byte-by-byte path. - iterator_is_contiguous now also allows std::sized_sentinel_for<SentinelType, IteratorType> under C++20, gated the same way as the existing std::contiguous_iterator detection. - get_elements_impl's fast path uses std::ranges::distance under C++20 (works for both same-type and sized-sentinel pairs) and falls back to std::distance pre-C++20, where SentinelType is always IteratorType. - Add a C++20-only test exercising json::parse/accept with std::counted_iterator + std::default_sentinel_t. - Document std::default_sentinel_t + std::counted_iterator as a SentinelType example across parse.md, accept.md, sax_parse.md, and the five from_*.md pages, replacing an earlier ambiguously worded bullet. Addresses review feedback: https://github.com/nlohmann/json/pull/5265#discussion_r3564237584 Signed-off-by: Niels Lohmann <mail@nlohmann.me>