[libcxx-commits] [libcxx] [libc++][ranges] Resolve LWG4242 (PR #211568)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Aug 5 22:59:31 PDT 2026
================
@@ -142,7 +142,7 @@
"`LWG4235 <https://wg21.link/LWG4235>`__","``cache_latest_view`` and ``to_input_view`` miss ``reserve_hint``","2025-06 (Sofia)","","","`#148219 <https://github.com/llvm/llvm-project/issues/148219>`__",""
"`LWG4236 <https://wg21.link/LWG4236>`__","``chunk_view::outer-iterator::value_type`` should provide ``reserve_hint``","2025-06 (Sofia)","","","`#148220 <https://github.com/llvm/llvm-project/issues/148220>`__",""
"`LWG4239 <https://wg21.link/LWG4239>`__","``flat_map``'s transparent comparator no longer works for string literals","2025-06 (Sofia)","","","`#148223 <https://github.com/llvm/llvm-project/issues/148223>`__",""
-"`LWG4242 <https://wg21.link/LWG4242>`__","``ranges::distance`` does not work with volatile iterators","2025-06 (Sofia)","","","`#148224 <https://github.com/llvm/llvm-project/issues/148224>`__",""
+"`LWG4242 <https://wg21.link/LWG4242>`__","``ranges::distance`` does not work with volatile iterators","2025-06 (Sofia)","|Complete|","24","`#148224 <https://github.com/llvm/llvm-project/issues/148224>`__",""
----------------
frederick-vs-ja wrote:
I'm becoming inclined to consider LWG4242 implemented in LLVM 14 (c965d5448ecdf9a5513983862a78a2ba8f7fbab8). This would be quite surprising, but seems better to consider it newly implemented. CC @hewillk.
```suggestion
"`LWG4242 <https://wg21.link/LWG4242>`__","``ranges::distance`` does not work with volatile iterators","2025-06 (Sofia)","|Complete|","14","`#148224 <https://github.com/llvm/llvm-project/issues/148224>`__",""
```
IIUC, in this `operator()`, `sized_sentinel_for<_Sp, __remove_cvref_t<_Ip>>` and `!is_array_v<remove_reference_t<_Ip>>` (as suggested by the resolution of LWG4242) give actually equivalent conditions.
Reasons:
1. The branch returning `__last - decay_t<_Ip>(__first)` can only be entered when `__remove_cvref_t<_Ip>` and `decay_t<_Ip>` are different types.
2. Only array and function types and reference types thereof can make `remove_cvref_t` and `decay_t` give different results.
3. If `_Ip` were a function, array, or reference to function or array type, `sized_sentinel_for<_Sp, remove_cvref_t<_Ip>>` wouldn't be satisfied. Because `sized_sentinel_for<S, I>` requires `input_or_output_iterator<I>`, which in turn requires `movable<I>`, which in turn requires `assignable_from<I&, I>`, and array and function types are not assignable.
Perhaps we can just improve test files and update documentation in this PR, and leave the shape change of this `operator()` to a separate NFC PR.
https://github.com/llvm/llvm-project/pull/211568
More information about the libcxx-commits
mailing list