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

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jun 29 00:49:24 PDT 2026


================
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: std-at-least-c++26
+
+// std::ranges::reserve_hint
+
+#include <ranges>
+
+extern int arr[];
+
+// Verify that for an array of unknown bound `ranges::reserve_hint` is ill-formed.
+void test() {
+  std::ranges::reserve_hint(arr);
----------------
philnik777 wrote:

Well, that should definitely be refactored. You simply have to check via a `requires` whether the function is callable.

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


More information about the libcxx-commits mailing list