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

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jun 28 21:07:37 PDT 2026


================
@@ -129,6 +130,24 @@ class stride_view : public view_interface<stride_view<_View>> {
   {
     return std::__to_unsigned_like(ranges::__div_ceil(ranges::distance(__base_), __stride_));
   }
+
+#  if _LIBCPP_STD_VER >= 26
+
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto reserve_hint()
+    requires approximately_sized_range<_View>
+  {
+    auto __s = static_cast<range_difference_t<decltype((__base_))>>(ranges::reserve_hint(__base_));
+    return __to_unsigned_like(__div_ceil(__s, __stride_));
----------------
frederick-vs-ja wrote:

We should use qualified calls to function templates to get rid of ADL (unless ADL is required).
```suggestion
    return std::__to_unsigned_like(ranges::__div_ceil(__s, __stride_));
```
(Same for all `__to_unsigned_like` and `__div_ceil` calls.)

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


More information about the libcxx-commits mailing list