[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 18:39:44 PDT 2026


================
@@ -131,6 +131,59 @@ inline constexpr auto ssize = __ssize::__fn{};
 } // namespace __cpo
 } // namespace ranges
 
+#  if _LIBCPP_STD_VER >= 26
+
+// [range.prim.size.hint]
+
+namespace ranges {
+namespace __reserve_hint {
+void reserve_hint() = delete;
+
+template <typename _Tp>
+concept __std_size = requires(_Tp&& __t) { ranges::size(__t); };
+
+template <typename _Tp>
+concept __member_reserve_hint = !__std_size<_Tp> && requires(_Tp&& __t) {
+  { auto(__t.reserve_hint()) } -> __integer_like;
+};
+
+template <typename _Tp>
+concept __freestanding_reserve_hint =
----------------
frederick-vs-ja wrote:

The word "freestanding" used here has completely different meaning from the meaning used in the standard. Can we choose another word, e.g. `nonmember` or `free`?

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


More information about the libcxx-commits mailing list