[libcxx-commits] [libcxx] [libc++][ranges] Ensure range access CPOs are provided in `<iterator>` (PR #151745)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Fri Aug 15 06:31:07 PDT 2025


================
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// 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++20
+
+// [range.access.general]/1:
+// In addition to being available via inclusion of the <ranges> header, the customization point objects in
+// [range.access] are available when the header <iterator> is included.
+
+#include <iterator>
+#include <type_traits>
+
+#include "test_macros.h"
+
+template <class CPO, class... Args>
+constexpr bool test(CPO& o, Args&&...) {
+  static_assert(std::is_const_v<CPO>);
+  static_assert(std::is_class_v<CPO>);
+  static_assert(std::is_trivially_copyable_v<CPO>);
+  static_assert(std::is_trivially_default_constructible_v<CPO>);
+
+  auto p  = o;
----------------
frederick-vs-ja wrote:

Ah, given we actually call CPOs, it perhaps makes more sense to test both compile time and runtime invocability. I'm now changing the test file to `.pass.cpp`.

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


More information about the libcxx-commits mailing list