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

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Fri Aug 7 03:55:09 PDT 2026


================
@@ -139,6 +140,30 @@ class adjacent_view : public view_interface<adjacent_view<_View, _Np>> {
     __sz -= std::min<_CT>(__sz, _Np - 1);
     return static_cast<_ST>(__sz);
   }
+
+#  if _LIBCPP_STD_VER >= 26
+
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto reserve_hint()
+    requires approximately_sized_range<_View>
+  {
+    using _ST = decltype(ranges::reserve_hint(__base_));
+    using _CT = common_type_t<_ST, size_t>;
+    auto __sz = static_cast<_CT>(ranges::reserve_hint(__base_));
+    __sz -= std::min<_CT>(__sz, _Np - 1);
+    return static_cast<_ST>(__sz);
----------------
Zingam wrote:

```suggestion
    return to-unsigned-like(sz);
```
Reminder: Don't forget this line too! (Ditto bellow)

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


More information about the libcxx-commits mailing list