[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


================
@@ -176,6 +176,28 @@ class concat_view : public view_interface<concat_view<_Views...>> {
         [](auto... __sizes) { return (make_unsigned_t<common_type_t<decltype(__sizes)...>>(__sizes) + ...); },
         std::__tuple_transform(ranges::size, __views_));
   }
+
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto reserve_hint()
+    requires(approximately_sized_range<_Views> && ...)
+  {
+    return apply(
+        [](auto... __sizes) static {
+          using _CT = make_unsigned_t<common_type_t<decltype(__sizes)...>>;
+          return (_CT(__sizes) + ...);
----------------
frederick-vs-ja wrote:

No change requested for this.
I guess we should handle overflow (wrapping) here. Maybe there should a follow-up LWG issue. CC @huixie90.

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


More information about the libcxx-commits mailing list