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

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Aug 7 00:47:44 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_));
----------------
inquisitivecrystal wrote:

That's a *really* good catch. The implementation for the `size` function it is quoted immediately before the new implementation for `reserve_hint` in the proposal, as an anchor to show where the new text should be inserted into the specification. In a lot of cases, the `reserve_hint` implementation is just the `size` implementation modified to call `ranges::reserve_hint` instead of `ranges::size`. I must have inadvertently followed that pattern even though this instance is different, which is an embarrassing mistake on my part. Thank you so much for catching this, I'll be sure to fix it.

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


More information about the libcxx-commits mailing list