[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 02:35:08 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:

The suggested above is the common style in this code base. For shorter `#if #else #endif` blocks the closing comment is avoided, for longer ones the closing comment matches the opening condition.

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


More information about the libcxx-commits mailing list