[libcxx-commits] [libcxx] [libc++] Partially implement P2846R6: `reserve_hint` (PR #206385)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Aug 7 01:00:05 PDT 2026
================
@@ -80,10 +81,24 @@ using range_rvalue_reference_t = iter_rvalue_reference_t<iterator_t<_Rp>>;
template <range _Rp>
using range_common_reference_t = iter_common_reference_t<iterator_t<_Rp>>;
+# if _LIBCPP_STD_VER >= 26
+
+// [range.approximately.sized]
+template <class _Tp>
+concept approximately_sized_range = range<_Tp> && requires(_Tp& __t) { ranges::reserve_hint(__t); };
+
+// [range.sized]
+template <class _Tp>
+concept sized_range = approximately_sized_range<_Tp> && requires(_Tp& __t) { ranges::size(__t); };
+
+# else
+
// [range.sized]
template <class _Tp>
concept sized_range = range<_Tp> && requires(_Tp& __t) { ranges::size(__t); };
+# endif
----------------
inquisitivecrystal wrote:
The problem here is that this is actually closing the `# else` branch, which is executed if `_LIBCPP_STD_VER < 26`. So commenting `_LIBCPP_STD_VER >= 26` seemed confusing to me; it makes it easier to skip over the `# else` that actually governs the code directly above. I thought about commenting the `# else` with `_LIBCPP_STD_VER < 26` and then commenting this the same, but there didn't seem to be a lot of precedent for doing that. I ended up just skipping the comment.
https://github.com/llvm/llvm-project/pull/206385
More information about the libcxx-commits
mailing list