[libcxx-commits] [libcxx] [libc++] Partially implement P2846R6: `reserve_hint` (PR #206385)

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Thu Aug 6 02:02:14 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
----------------
Zingam wrote:

Nit: (since you already do this elsewhere and it is nice to have it to ease readability.)

```suggestion
#  endif // _LIBCPP_STD_VER >= 26
```

https://github.com/llvm/llvm-project/pull/206385


More information about the libcxx-commits mailing list