[libcxx-commits] [libcxx] [libc++][NFC] Create and use test-defined simple_view concept (PR #77334)

Will Hawkins via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jan 8 19:33:59 PST 2024


https://github.com/hawkinsw updated https://github.com/llvm/llvm-project/pull/77334

>From 63247287048d09cb5e8a910e72062f416a169912 Mon Sep 17 00:00:00 2001
From: Will Hawkins <hawkinsw at obs.cr>
Date: Mon, 8 Jan 2024 11:19:40 -0500
Subject: [PATCH 1/4] [libc++][NFC] Create and use test-defined simple_view
 concept

Instead of using a concept defined in the internal implementation,
use a definition of the simple_view ranges concept separately
defined and included in test code.
---
 .../range.adaptors/range.drop/begin.pass.cpp  |  5 +-
 .../ranges/range.adaptors/range.drop/types.h  | 14 ++---
 .../range.adaptors/range.elements/types.h     |  8 +--
 .../range.join.sentinel/ctor.other.pass.cpp   |  3 +-
 .../ranges/range.adaptors/range.join/types.h  | 17 +++---
 .../range.lazy.split/begin.pass.cpp           | 17 +++---
 .../range.lazy.split/end.pass.cpp             |  9 +--
 .../range.adaptors/range.take.while/types.h   |  4 +-
 .../range.adaptors/range.take/begin.pass.cpp  |  2 +-
 .../range.zip/sentinel/ctor.other.pass.cpp    |  2 +-
 .../range.zip/sentinel/eq.pass.cpp            |  8 +--
 .../range.zip/sentinel/minus.pass.cpp         |  6 +-
 .../ranges/range.adaptors/range.zip/types.h   | 56 +++++++++----------
 libcxx/test/support/test_range.h              |  7 +++
 14 files changed, 85 insertions(+), 73 deletions(-)

diff --git a/libcxx/test/std/ranges/range.adaptors/range.drop/begin.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.drop/begin.pass.cpp
index 8c28769acf7fbf..28ac53c2445d4b 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.drop/begin.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.drop/begin.pass.cpp
@@ -18,6 +18,7 @@
 
 #include "test_macros.h"
 #include "test_iterators.h"
+#include "test_range.h"
 #include "types.h"
 
 template<class T>
@@ -122,7 +123,7 @@ constexpr bool test() {
   {
     static_assert(std::ranges::random_access_range<const SimpleView>);
     static_assert(std::ranges::sized_range<const SimpleView>);
-    LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<SimpleView>);
+    static_assert(simple_view<SimpleView>);
     int non_const_calls = 0;
     int const_calls = 0;
     std::ranges::drop_view dropView(SimpleView{{}, &non_const_calls, &const_calls}, 4);
@@ -137,7 +138,7 @@ constexpr bool test() {
   {
     static_assert(std::ranges::random_access_range<const NonSimpleView>);
     static_assert(std::ranges::sized_range<const NonSimpleView>);
-    LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<NonSimpleView>);
+    static_assert(!simple_view<NonSimpleView>);
     int non_const_calls = 0;
     int const_calls = 0;
     std::ranges::drop_view dropView(NonSimpleView{{}, &non_const_calls, &const_calls}, 4);
diff --git a/libcxx/test/std/ranges/range.adaptors/range.drop/types.h b/libcxx/test/std/ranges/range.adaptors/range.drop/types.h
index 1fc3f05bf5eaab..ae861bce40f1ec 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.drop/types.h
+++ b/libcxx/test/std/ranges/range.adaptors/range.drop/types.h
@@ -15,21 +15,21 @@
 int globalBuff[8];
 
 template <class T>
-struct sentinel {
+struct drop_sentinel {
   T* ptr_;
   int* num_of_sentinel_cmp_calls;
 
 public:
-  friend constexpr bool operator==(sentinel const s, T* const ptr) noexcept {
+  friend constexpr bool operator==(drop_sentinel const s, T* const ptr) noexcept {
     ++(*s.num_of_sentinel_cmp_calls);
     return {s.ptr_ == ptr};
   }
-  friend constexpr bool operator==(T* const ptr, sentinel const s) noexcept {
+  friend constexpr bool operator==(T* const ptr, drop_sentinel const s) noexcept {
     ++(*s.num_of_sentinel_cmp_calls);
     return {s.ptr_ == ptr};
   }
-  friend constexpr bool operator!=(sentinel const s, T* const ptr) noexcept { return !(s == ptr); }
-  friend constexpr bool operator!=(T* const ptr, sentinel const s) noexcept { return !(s == ptr); }
+  friend constexpr bool operator!=(drop_sentinel const s, T* const ptr) noexcept { return !(s == ptr); }
+  friend constexpr bool operator!=(T* const ptr, drop_sentinel const s) noexcept { return !(s == ptr); }
 };
 
 template <bool IsSimple>
@@ -39,9 +39,9 @@ struct MaybeSimpleNonCommonView : std::ranges::view_base {
   constexpr std::size_t size() const { return 8; }
   constexpr int* begin() { return globalBuff + start_; }
   constexpr std::conditional_t<IsSimple, int*, const int*> begin() const { return globalBuff + start_; }
-  constexpr sentinel<int> end() { return sentinel<int>{globalBuff + size(), num_of_sentinel_cmp_calls}; }
+  constexpr drop_sentinel<int> end() { return drop_sentinel<int>{globalBuff + size(), num_of_sentinel_cmp_calls}; }
   constexpr auto end() const {
-    return std::conditional_t<IsSimple, sentinel<int>, sentinel<const int>>{
+    return std::conditional_t<IsSimple, drop_sentinel<int>, drop_sentinel<const int>>{
         globalBuff + size(), num_of_sentinel_cmp_calls};
   }
 };
diff --git a/libcxx/test/std/ranges/range.adaptors/range.elements/types.h b/libcxx/test/std/ranges/range.adaptors/range.elements/types.h
index f1ee165c3cc636..4c4084695ff332 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.elements/types.h
+++ b/libcxx/test/std/ranges/range.adaptors/range.elements/types.h
@@ -58,8 +58,8 @@ using NonSimpleCommonRandomAccessSized = NonSimpleCommon;
 static_assert(std::ranges::common_range<Common<true>>);
 static_assert(std::ranges::random_access_range<SimpleCommon>);
 static_assert(std::ranges::sized_range<SimpleCommon>);
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<SimpleCommon>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<NonSimpleCommon>);
+static_assert(simple_view<SimpleCommon>);
+static_assert(!simple_view<NonSimpleCommon>);
 
 template <bool Simple>
 struct NonCommon : TupleBufferView {
@@ -86,8 +86,8 @@ using NonSimpleNonCommon = NonCommon<false>;
 static_assert(!std::ranges::common_range<SimpleNonCommon>);
 static_assert(std::ranges::random_access_range<SimpleNonCommon>);
 static_assert(!std::ranges::sized_range<SimpleNonCommon>);
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<SimpleNonCommon>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<NonSimpleNonCommon>);
+static_assert(simple_view<SimpleNonCommon>);
+static_assert(!simple_view<NonSimpleNonCommon>);
 
 template <class Derived>
 struct IterBase {
diff --git a/libcxx/test/std/ranges/range.adaptors/range.join/range.join.sentinel/ctor.other.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.join/range.join.sentinel/ctor.other.pass.cpp
index 5ef3e7416ef10b..fb1e8eb1ebefa6 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.join/range.join.sentinel/ctor.other.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.join/range.join.sentinel/ctor.other.pass.cpp
@@ -15,6 +15,7 @@
 #include <ranges>
 
 #include "../types.h"
+#include "test_range.h"
 
 template <class T>
 struct convertible_sentinel_wrapper {
@@ -45,7 +46,7 @@ struct ConstConvertibleView : BufferView<BufferView<int*>*> {
 static_assert(!std::ranges::common_range<ConstConvertibleView>);
 static_assert(std::convertible_to<std::ranges::sentinel_t<ConstConvertibleView>,
                                   std::ranges::sentinel_t<ConstConvertibleView const>>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<ConstConvertibleView>);
+static_assert(!simple_view<ConstConvertibleView>);
 
 constexpr bool test() {
   int buffer[4][4] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}};
diff --git a/libcxx/test/std/ranges/range.adaptors/range.join/types.h b/libcxx/test/std/ranges/range.adaptors/range.join/types.h
index c1378dc1144b40..175eb316030e9c 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.join/types.h
+++ b/libcxx/test/std/ranges/range.adaptors/range.join/types.h
@@ -16,6 +16,7 @@
 
 #include "test_macros.h"
 #include "test_iterators.h"
+#include "test_range.h"
 
 inline int globalBuffer[4][4] = {
     {1111, 2222, 3333, 4444},
@@ -239,7 +240,7 @@ using SimpleInputCommonOuter = BufferView<common_input_iterator<Inner*>>;
 static_assert(!std::ranges::forward_range<SimpleInputCommonOuter<>>);
 static_assert(!std::ranges::bidirectional_range<SimpleInputCommonOuter<>>);
 static_assert(std::ranges::common_range<SimpleInputCommonOuter<>>);
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<SimpleInputCommonOuter<>>);
+static_assert(simple_view<SimpleInputCommonOuter<>>);
 
 template <class Inner = BufferView<int*>>
 using NonSimpleInputCommonOuter = BufferView<common_input_iterator<const Inner*>, common_input_iterator<const Inner*>,
@@ -247,14 +248,14 @@ using NonSimpleInputCommonOuter = BufferView<common_input_iterator<const Inner*>
 static_assert(!std::ranges::forward_range<NonSimpleInputCommonOuter<>>);
 static_assert(!std::ranges::bidirectional_range<NonSimpleInputCommonOuter<>>);
 static_assert(std::ranges::common_range<NonSimpleInputCommonOuter<>>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<NonSimpleInputCommonOuter<>>);
+static_assert(!simple_view<NonSimpleInputCommonOuter<>>);
 
 template <class Inner = BufferView<int*>>
 using SimpleForwardCommonOuter = BufferView<forward_iterator<Inner*>>;
 static_assert(std::ranges::forward_range<SimpleForwardCommonOuter<>>);
 static_assert(!std::ranges::bidirectional_range<SimpleForwardCommonOuter<>>);
 static_assert(std::ranges::common_range<SimpleForwardCommonOuter<>>);
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<SimpleForwardCommonOuter<>>);
+static_assert(simple_view<SimpleForwardCommonOuter<>>);
 
 template <class Inner = BufferView<int*>>
 using NonSimpleForwardCommonOuter = BufferView<forward_iterator<const Inner*>, forward_iterator<const Inner*>,
@@ -262,14 +263,14 @@ using NonSimpleForwardCommonOuter = BufferView<forward_iterator<const Inner*>, f
 static_assert(std::ranges::forward_range<NonSimpleForwardCommonOuter<>>);
 static_assert(!std::ranges::bidirectional_range<NonSimpleForwardCommonOuter<>>);
 static_assert(std::ranges::common_range<NonSimpleForwardCommonOuter<>>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<NonSimpleForwardCommonOuter<>>);
+static_assert(!simple_view<NonSimpleForwardCommonOuter<>>);
 
 template <class Inner = BufferView<int*>>
 using SimpleForwardNonCommonOuter = BufferView<forward_iterator<Inner*>, sentinel_wrapper<forward_iterator<Inner*>>>;
 static_assert(std::ranges::forward_range<SimpleForwardNonCommonOuter<>>);
 static_assert(!std::ranges::bidirectional_range<SimpleForwardNonCommonOuter<>>);
 static_assert(!std::ranges::common_range<SimpleForwardNonCommonOuter<>>);
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<SimpleForwardNonCommonOuter<>>);
+static_assert(simple_view<SimpleForwardNonCommonOuter<>>);
 
 template <class Inner = BufferView<int*>>
 using NonSimpleForwardNonCommonOuter =
@@ -278,13 +279,13 @@ using NonSimpleForwardNonCommonOuter =
 static_assert(std::ranges::forward_range<NonSimpleForwardNonCommonOuter<>>);
 static_assert(!std::ranges::bidirectional_range<NonSimpleForwardNonCommonOuter<>>);
 static_assert(!std::ranges::common_range<NonSimpleForwardNonCommonOuter<>>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<NonSimpleForwardNonCommonOuter<>>);
+static_assert(!simple_view<NonSimpleForwardNonCommonOuter<>>);
 
 template <class Inner = BufferView<int*>>
 using BidiCommonOuter = BufferView<bidirectional_iterator<Inner*>>;
 static_assert(std::ranges::bidirectional_range<BidiCommonOuter<>>);
 static_assert(std::ranges::common_range<BidiCommonOuter<>>);
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<BidiCommonOuter<>>);
+static_assert(simple_view<BidiCommonOuter<>>);
 
 // an iterator where its operator* makes a copy of underlying operator*
 template <class It>
@@ -349,7 +350,7 @@ struct InnerRValue : Outer {
 static_assert(std::ranges::forward_range<InnerRValue<SimpleForwardCommonOuter<>>>);
 static_assert(!std::ranges::bidirectional_range<InnerRValue<SimpleForwardCommonOuter<>>>);
 static_assert(std::ranges::common_range<InnerRValue<SimpleForwardCommonOuter<>>>);
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<InnerRValue<SimpleForwardCommonOuter<>>>);
+static_assert(simple_view<InnerRValue<SimpleForwardCommonOuter<>>>);
 static_assert(!std::is_lvalue_reference_v<std::ranges::range_reference_t<InnerRValue<SimpleForwardCommonOuter<>>>>);
 
 struct move_swap_aware_iter {
diff --git a/libcxx/test/std/ranges/range.adaptors/range.lazy.split/begin.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.lazy.split/begin.pass.cpp
index c89da85155d090..113272703d59fd 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.lazy.split/begin.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.lazy.split/begin.pass.cpp
@@ -16,6 +16,7 @@
 #include <cassert>
 #include <utility>
 #include "test_iterators.h"
+#include "test_range.h"
 #include "types.h"
 
 template <class View>
@@ -32,8 +33,8 @@ constexpr bool test() {
 
     static_assert(std::ranges::forward_range<V>);
     static_assert(std::ranges::forward_range<const V>);
-    LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<V>);
-    LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<P>);
+    static_assert(simple_view<V>);
+    static_assert(simple_view<P>);
 
     {
       std::ranges::lazy_split_view<V, P> v;
@@ -58,8 +59,8 @@ constexpr bool test() {
 
     static_assert(std::ranges::forward_range<V>);
     static_assert(std::ranges::forward_range<const V>);
-    LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<V>);
-    LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<P>);
+    static_assert(!simple_view<V>);
+    static_assert(!simple_view<P>);
 
     {
       std::ranges::lazy_split_view<V, P> v;
@@ -83,8 +84,8 @@ constexpr bool test() {
     using P = V;
     static_assert(std::ranges::forward_range<V>);
     static_assert(!std::ranges::forward_range<const V>);
-    LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<V>);
-    LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<P>);
+    static_assert(!simple_view<V>);
+    static_assert(!simple_view<P>);
 
     std::ranges::lazy_split_view<V, P> v;
     auto it = v.begin();
@@ -102,8 +103,8 @@ constexpr bool test() {
 
     static_assert(std::ranges::forward_range<V>);
     static_assert(std::ranges::forward_range<const V>);
-    LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<V>);
-    LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<P>);
+    static_assert(simple_view<V>);
+    static_assert(!simple_view<P>);
 
     {
       std::ranges::lazy_split_view<V, P> v;
diff --git a/libcxx/test/std/ranges/range.adaptors/range.lazy.split/end.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.lazy.split/end.pass.cpp
index 0f5ab62650429a..3e3facc1cbe3da 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.lazy.split/end.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.lazy.split/end.pass.cpp
@@ -16,6 +16,7 @@
 #include <cassert>
 #include <utility>
 #include "test_iterators.h"
+#include "test_range.h"
 #include "types.h"
 
 struct ForwardViewCommonIfConst : std::ranges::view_base {
@@ -59,8 +60,8 @@ constexpr bool test() {
 
     static_assert(std::ranges::forward_range<V>);
     static_assert(std::ranges::common_range<const V>);
-    LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<V>);
-    LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<P>);
+    static_assert(simple_view<V>);
+    static_assert(simple_view<P>);
 
     {
       std::ranges::lazy_split_view<V, P> v;
@@ -85,8 +86,8 @@ constexpr bool test() {
 
     static_assert(std::ranges::forward_range<V>);
     static_assert(std::ranges::common_range<V>);
-    LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<V>);
-    LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<P>);
+    static_assert(simple_view<V>);
+    static_assert(!simple_view<P>);
     static_assert(std::ranges::forward_range<const V>);
     static_assert(std::ranges::common_range<const V>);
 
diff --git a/libcxx/test/std/ranges/range.adaptors/range.take.while/types.h b/libcxx/test/std/ranges/range.adaptors/range.take.while/types.h
index b946190d3fd801..8a8119970c582c 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.take.while/types.h
+++ b/libcxx/test/std/ranges/range.adaptors/range.take.while/types.h
@@ -36,7 +36,7 @@ struct SimpleView : IntBufferViewBase {
   constexpr int* begin() const { return buffer_; }
   constexpr int* end() const { return buffer_ + size_; }
 };
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<SimpleView>);
+static_assert(simple_view<SimpleView>);
 
 struct ConstNotRange : IntBufferViewBase {
   using IntBufferViewBase::IntBufferViewBase;
@@ -54,6 +54,6 @@ struct NonSimple : IntBufferViewBase {
   constexpr int* end() { return buffer_ + size_; }
 };
 static_assert(std::ranges::view<NonSimple>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<NonSimple>);
+static_assert(!simple_view<NonSimple>);
 
 #endif // TEST_STD_RANGES_RANGE_ADAPTORS_RANGE_TAKE_WHILE_TYPES_H
diff --git a/libcxx/test/std/ranges/range.adaptors/range.take/begin.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.take/begin.pass.cpp
index f2ac62e764d59e..0946542fdca9ed 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.take/begin.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.take/begin.pass.cpp
@@ -69,7 +69,7 @@ constexpr bool test() {
     ASSERT_SAME_TYPE(decltype(tv.begin()), std::counted_iterator<int*>);
   }
 
-  // __simple_view<V> && sized_range<V> && !size_range<!V>
+  // simple_view<V> && sized_range<V> && !size_range<!V>
   {
     std::ranges::take_view<NonCommonSimpleView> tv{};
     ASSERT_SAME_TYPE(decltype(tv.begin()), std::counted_iterator<int*>);
diff --git a/libcxx/test/std/ranges/range.adaptors/range.zip/sentinel/ctor.other.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.zip/sentinel/ctor.other.pass.cpp
index 9635d9a11988c3..11ad73c313c590 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.zip/sentinel/ctor.other.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.zip/sentinel/ctor.other.pass.cpp
@@ -46,7 +46,7 @@ static_assert(std::ranges::random_access_range<NonSimpleNonCommonConvertibleView
 static_assert(!std::ranges::sized_range<NonSimpleNonCommonConvertibleView>);
 static_assert(std::convertible_to<std::ranges::sentinel_t<NonSimpleNonCommonConvertibleView>,
                                   std::ranges::sentinel_t<NonSimpleNonCommonConvertibleView const>>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<NonSimpleNonCommonConvertibleView>);
+static_assert(!simple_view<NonSimpleNonCommonConvertibleView>);
 
 constexpr bool test() {
   int buffer1[4] = {1, 2, 3, 4};
diff --git a/libcxx/test/std/ranges/range.adaptors/range.zip/sentinel/eq.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.zip/sentinel/eq.pass.cpp
index b42ec78cbb7f08..5db73721108141 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.zip/sentinel/eq.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.zip/sentinel/eq.pass.cpp
@@ -67,7 +67,7 @@ constexpr bool test() {
     // simple-view: const and non-const have the same iterator/sentinel type
     std::ranges::zip_view v{SimpleNonCommon(buffer1), SimpleNonCommon(buffer2), SimpleNonCommon(buffer3)};
     static_assert(!std::ranges::common_range<decltype(v)>);
-    LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<decltype(v)>);
+    static_assert(simple_view<decltype(v)>);
 
     assert(v.begin() != v.end());
     assert(v.begin() + 1 != v.end());
@@ -80,7 +80,7 @@ constexpr bool test() {
     // !simple-view: const and non-const have different iterator/sentinel types
     std::ranges::zip_view v{NonSimpleNonCommon(buffer1), SimpleNonCommon(buffer2), SimpleNonCommon(buffer3)};
     static_assert(!std::ranges::common_range<decltype(v)>);
-    LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<decltype(v)>);
+    static_assert(!simple_view<decltype(v)>);
 
     assert(v.begin() != v.end());
     assert(v.begin() + 4 == v.end());
@@ -105,7 +105,7 @@ constexpr bool test() {
     // underlying const/non-const sentinel can be compared with both const/non-const iterator
     std::ranges::zip_view v{ComparableView(buffer1), ComparableView(buffer2)};
     static_assert(!std::ranges::common_range<decltype(v)>);
-    LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<decltype(v)>);
+    static_assert(!simple_view<decltype(v)>);
 
     assert(v.begin() != v.end());
     assert(v.begin() + 4 == v.end());
@@ -130,7 +130,7 @@ constexpr bool test() {
     // underlying const/non-const sentinel cannot be compared with non-const/const iterator
     std::ranges::zip_view v{ComparableView(buffer1), ConstIncompatibleView{}};
     static_assert(!std::ranges::common_range<decltype(v)>);
-    LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<decltype(v)>);
+    static_assert(!simple_view<decltype(v)>);
 
     using Iter = std::ranges::iterator_t<decltype(v)>;
     using ConstIter = std::ranges::iterator_t<const decltype(v)>;
diff --git a/libcxx/test/std/ranges/range.adaptors/range.zip/sentinel/minus.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.zip/sentinel/minus.pass.cpp
index e46ab4c38d2b6b..be0a7ba5b907ed 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.zip/sentinel/minus.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.zip/sentinel/minus.pass.cpp
@@ -120,7 +120,7 @@ constexpr bool test() {
     // simple-view
     std::ranges::zip_view v{ForwardSizedNonCommon(buffer1)};
     static_assert(!std::ranges::common_range<decltype(v)>);
-    LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<decltype(v)>);
+    static_assert(simple_view<decltype(v)>);
 
     auto it = v.begin();
     auto st = v.end();
@@ -159,7 +159,7 @@ constexpr bool test() {
     // underlying sentinels cannot subtract underlying const iterators
     std::ranges::zip_view v(NonSimpleForwardSizedNonCommon{buffer1});
     static_assert(!std::ranges::common_range<decltype(v)>);
-    LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<decltype(v)>);
+    static_assert(!simple_view<decltype(v)>);
 
     using Iter = std::ranges::iterator_t<decltype(v)>;
     using ConstIter = std::ranges::iterator_t<const decltype(v)>;
@@ -191,7 +191,7 @@ constexpr bool test() {
     // const compatible allow non-const to const conversion
     std::ranges::zip_view v(ConstCompatibleForwardSized{buffer1});
     static_assert(!std::ranges::common_range<decltype(v)>);
-    LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<decltype(v)>);
+    static_assert(!simple_view<decltype(v)>);
 
     using Iter = std::ranges::iterator_t<decltype(v)>;
     using ConstIter = std::ranges::iterator_t<const decltype(v)>;
diff --git a/libcxx/test/std/ranges/range.adaptors/range.zip/types.h b/libcxx/test/std/ranges/range.adaptors/range.zip/types.h
index e5f399f93e358c..e084dcfc41b0d9 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.zip/types.h
+++ b/libcxx/test/std/ranges/range.adaptors/range.zip/types.h
@@ -57,8 +57,8 @@ using NonSimpleCommonRandomAccessSized = NonSimpleCommon;
 static_assert(std::ranges::common_range<Common<true>>);
 static_assert(std::ranges::random_access_range<SimpleCommon>);
 static_assert(std::ranges::sized_range<SimpleCommon>);
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<SimpleCommon>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<NonSimpleCommon>);
+static_assert(simple_view<SimpleCommon>);
+static_assert(!simple_view<NonSimpleCommon>);
 
 template <bool Simple>
 struct CommonNonRandom : IntBufferView {
@@ -83,8 +83,8 @@ using NonSimpleCommonNonRandom = CommonNonRandom<false>;
 static_assert(std::ranges::common_range<SimpleCommonNonRandom>);
 static_assert(!std::ranges::random_access_range<SimpleCommonNonRandom>);
 static_assert(!std::ranges::sized_range<SimpleCommonNonRandom>);
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<SimpleCommonNonRandom>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<NonSimpleCommonNonRandom>);
+static_assert(simple_view<SimpleCommonNonRandom>);
+static_assert(!simple_view<NonSimpleCommonNonRandom>);
 
 template <bool Simple>
 struct NonCommon : IntBufferView {
@@ -107,8 +107,8 @@ using NonSimpleNonCommon = NonCommon<false>;
 static_assert(!std::ranges::common_range<SimpleNonCommon>);
 static_assert(std::ranges::random_access_range<SimpleNonCommon>);
 static_assert(!std::ranges::sized_range<SimpleNonCommon>);
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<SimpleNonCommon>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<NonSimpleNonCommon>);
+static_assert(simple_view<SimpleNonCommon>);
+static_assert(!simple_view<NonSimpleNonCommon>);
 
 template <bool Simple>
 struct NonCommonSized : IntBufferView {
@@ -134,8 +134,8 @@ using NonSimpleNonCommonRandomAccessSized = NonSimpleNonCommonSized;
 static_assert(!std::ranges::common_range<SimpleNonCommonSized>);
 static_assert(std::ranges::random_access_range<SimpleNonCommonSized>);
 static_assert(std::ranges::sized_range<SimpleNonCommonSized>);
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<SimpleNonCommonSized>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<NonSimpleNonCommonSized>);
+static_assert(simple_view<SimpleNonCommonSized>);
+static_assert(!simple_view<NonSimpleNonCommonSized>);
 
 template <bool Simple>
 struct NonCommonNonRandom : IntBufferView {
@@ -164,8 +164,8 @@ using NonSimpleNonCommonNonRandom = NonCommonNonRandom<false>;
 static_assert(!std::ranges::common_range<SimpleNonCommonNonRandom>);
 static_assert(!std::ranges::random_access_range<SimpleNonCommonNonRandom>);
 static_assert(!std::ranges::sized_range<SimpleNonCommonNonRandom>);
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<SimpleNonCommonNonRandom>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<NonSimpleNonCommonNonRandom>);
+static_assert(simple_view<SimpleNonCommonNonRandom>);
+static_assert(!simple_view<NonSimpleNonCommonNonRandom>);
 
 template <class Iter, class Sent = Iter, class NonConstIter = Iter, class NonConstSent = Sent>
 struct BasicView : IntBufferView {
@@ -230,7 +230,7 @@ static_assert(std::ranges::forward_range<ForwardSizedView>);
 static_assert(std::ranges::sized_range<ForwardSizedView>);
 static_assert(std::ranges::common_range<ForwardSizedView>);
 static_assert(!std::ranges::random_access_range<ForwardSizedView>);
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<ForwardSizedView>);
+static_assert(simple_view<ForwardSizedView>);
 
 using NonSimpleForwardSizedView = BasicView<forward_sized_iterator<const int*>, forward_sized_iterator<const int*>,
                                             forward_sized_iterator<int*>, forward_sized_iterator<int*>>;
@@ -238,14 +238,14 @@ static_assert(std::ranges::forward_range<NonSimpleForwardSizedView>);
 static_assert(std::ranges::sized_range<NonSimpleForwardSizedView>);
 static_assert(std::ranges::common_range<NonSimpleForwardSizedView>);
 static_assert(!std::ranges::random_access_range<NonSimpleForwardSizedView>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<NonSimpleForwardSizedView>);
+static_assert(!simple_view<NonSimpleForwardSizedView>);
 
 using ForwardSizedNonCommon = BasicView<forward_sized_iterator<>, sized_sentinel<forward_sized_iterator<>>>;
 static_assert(std::ranges::forward_range<ForwardSizedNonCommon>);
 static_assert(std::ranges::sized_range<ForwardSizedNonCommon>);
 static_assert(!std::ranges::common_range<ForwardSizedNonCommon>);
 static_assert(!std::ranges::random_access_range<ForwardSizedNonCommon>);
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<ForwardSizedNonCommon>);
+static_assert(simple_view<ForwardSizedNonCommon>);
 
 using NonSimpleForwardSizedNonCommon =
     BasicView<forward_sized_iterator<const int*>, sized_sentinel<forward_sized_iterator<const int*>>,
@@ -254,7 +254,7 @@ static_assert(std::ranges::forward_range<NonSimpleForwardSizedNonCommon>);
 static_assert(std::ranges::sized_range<NonSimpleForwardSizedNonCommon>);
 static_assert(!std::ranges::common_range<NonSimpleForwardSizedNonCommon>);
 static_assert(!std::ranges::random_access_range<NonSimpleForwardSizedNonCommon>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<NonSimpleForwardSizedNonCommon>);
+static_assert(!simple_view<NonSimpleForwardSizedNonCommon>);
 
 struct SizedRandomAccessView : IntBufferView {
   using IntBufferView::IntBufferView;
@@ -275,7 +275,7 @@ static_assert(!std::ranges::contiguous_range<NonSizedRandomAccessView>);
 static_assert(std::ranges::random_access_range<SizedRandomAccessView>);
 static_assert(!std::ranges::common_range<NonSizedRandomAccessView>);
 static_assert(!std::ranges::sized_range<NonSizedRandomAccessView>);
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<NonSizedRandomAccessView>);
+static_assert(simple_view<NonSizedRandomAccessView>);
 
 using NonSimpleNonSizedRandomAccessView =
     BasicView<random_access_iterator<const int*>, sentinel_wrapper<random_access_iterator<const int*>>,
@@ -284,7 +284,7 @@ static_assert(!std::ranges::contiguous_range<NonSimpleNonSizedRandomAccessView>)
 static_assert(std::ranges::random_access_range<NonSimpleNonSizedRandomAccessView>);
 static_assert(!std::ranges::common_range<NonSimpleNonSizedRandomAccessView>);
 static_assert(!std::ranges::sized_range<NonSimpleNonSizedRandomAccessView>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<NonSimpleNonSizedRandomAccessView>);
+static_assert(!simple_view<NonSimpleNonSizedRandomAccessView>);
 
 using ContiguousCommonView = BasicView<int*>;
 static_assert(std::ranges::contiguous_range<ContiguousCommonView>);
@@ -306,20 +306,20 @@ using InputCommonView = BasicView<common_input_iterator<int*>>;
 static_assert(std::ranges::input_range<InputCommonView>);
 static_assert(!std::ranges::forward_range<InputCommonView>);
 static_assert(std::ranges::common_range<InputCommonView>);
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<InputCommonView>);
+static_assert(simple_view<InputCommonView>);
 
 using NonSimpleInputCommonView = BasicView<common_input_iterator<const int*>, common_input_iterator<const int*>,
                                            common_input_iterator<int*>, common_input_iterator<int*>>;
 static_assert(std::ranges::input_range<NonSimpleInputCommonView>);
 static_assert(!std::ranges::forward_range<NonSimpleInputCommonView>);
 static_assert(std::ranges::common_range<NonSimpleInputCommonView>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<NonSimpleInputCommonView>);
+static_assert(!simple_view<NonSimpleInputCommonView>);
 
 using InputNonCommonView = BasicView<common_input_iterator<int*>, sentinel_wrapper<common_input_iterator<int*>>>;
 static_assert(std::ranges::input_range<InputNonCommonView>);
 static_assert(!std::ranges::forward_range<InputNonCommonView>);
 static_assert(!std::ranges::common_range<InputNonCommonView>);
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<InputNonCommonView>);
+static_assert(simple_view<InputNonCommonView>);
 
 using NonSimpleInputNonCommonView =
     BasicView<common_input_iterator<const int*>, sentinel_wrapper<common_input_iterator<const int*>>,
@@ -327,14 +327,14 @@ using NonSimpleInputNonCommonView =
 static_assert(std::ranges::input_range<InputNonCommonView>);
 static_assert(!std::ranges::forward_range<InputNonCommonView>);
 static_assert(!std::ranges::common_range<InputNonCommonView>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<NonSimpleInputNonCommonView>);
+static_assert(!simple_view<NonSimpleInputNonCommonView>);
 
 using BidiCommonView = BasicView<bidirectional_iterator<int*>>;
 static_assert(!std::ranges::sized_range<BidiCommonView>);
 static_assert(std::ranges::bidirectional_range<BidiCommonView>);
 static_assert(!std::ranges::random_access_range<BidiCommonView>);
 static_assert(std::ranges::common_range<BidiCommonView>);
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<BidiCommonView>);
+static_assert(simple_view<BidiCommonView>);
 
 using NonSimpleBidiCommonView = BasicView<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>,
                                           bidirectional_iterator<int*>, bidirectional_iterator<int*>>;
@@ -342,7 +342,7 @@ static_assert(!std::ranges::sized_range<NonSimpleBidiCommonView>);
 static_assert(std::ranges::bidirectional_range<NonSimpleBidiCommonView>);
 static_assert(!std::ranges::random_access_range<NonSimpleBidiCommonView>);
 static_assert(std::ranges::common_range<NonSimpleBidiCommonView>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<NonSimpleBidiCommonView>);
+static_assert(!simple_view<NonSimpleBidiCommonView>);
 
 struct SizedBidiCommon : BidiCommonView {
   using BidiCommonView::BidiCommonView;
@@ -352,7 +352,7 @@ static_assert(std::ranges::sized_range<SizedBidiCommon>);
 static_assert(std::ranges::bidirectional_range<SizedBidiCommon>);
 static_assert(!std::ranges::random_access_range<SizedBidiCommon>);
 static_assert(std::ranges::common_range<SizedBidiCommon>);
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<SizedBidiCommon>);
+static_assert(simple_view<SizedBidiCommon>);
 
 struct NonSimpleSizedBidiCommon : NonSimpleBidiCommonView {
   using NonSimpleBidiCommonView::NonSimpleBidiCommonView;
@@ -362,14 +362,14 @@ static_assert(std::ranges::sized_range<NonSimpleSizedBidiCommon>);
 static_assert(std::ranges::bidirectional_range<NonSimpleSizedBidiCommon>);
 static_assert(!std::ranges::random_access_range<NonSimpleSizedBidiCommon>);
 static_assert(std::ranges::common_range<NonSimpleSizedBidiCommon>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<NonSimpleSizedBidiCommon>);
+static_assert(!simple_view<NonSimpleSizedBidiCommon>);
 
 using BidiNonCommonView = BasicView<bidirectional_iterator<int*>, sentinel_wrapper<bidirectional_iterator<int*>>>;
 static_assert(!std::ranges::sized_range<BidiNonCommonView>);
 static_assert(std::ranges::bidirectional_range<BidiNonCommonView>);
 static_assert(!std::ranges::random_access_range<BidiNonCommonView>);
 static_assert(!std::ranges::common_range<BidiNonCommonView>);
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<BidiNonCommonView>);
+static_assert(simple_view<BidiNonCommonView>);
 
 using NonSimpleBidiNonCommonView =
     BasicView<bidirectional_iterator<const int*>, sentinel_wrapper<bidirectional_iterator<const int*>>,
@@ -378,14 +378,14 @@ static_assert(!std::ranges::sized_range<NonSimpleBidiNonCommonView>);
 static_assert(std::ranges::bidirectional_range<NonSimpleBidiNonCommonView>);
 static_assert(!std::ranges::random_access_range<NonSimpleBidiNonCommonView>);
 static_assert(!std::ranges::common_range<NonSimpleBidiNonCommonView>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<NonSimpleBidiNonCommonView>);
+static_assert(!simple_view<NonSimpleBidiNonCommonView>);
 
 using SizedBidiNonCommonView = BasicView<bidirectional_iterator<int*>, sized_sentinel<bidirectional_iterator<int*>>>;
 static_assert(std::ranges::sized_range<SizedBidiNonCommonView>);
 static_assert(std::ranges::bidirectional_range<SizedBidiNonCommonView>);
 static_assert(!std::ranges::random_access_range<SizedBidiNonCommonView>);
 static_assert(!std::ranges::common_range<SizedBidiNonCommonView>);
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<SizedBidiNonCommonView>);
+static_assert(simple_view<SizedBidiNonCommonView>);
 
 using NonSimpleSizedBidiNonCommonView =
     BasicView<bidirectional_iterator<const int*>, sized_sentinel<bidirectional_iterator<const int*>>,
@@ -394,7 +394,7 @@ static_assert(std::ranges::sized_range<NonSimpleSizedBidiNonCommonView>);
 static_assert(std::ranges::bidirectional_range<NonSimpleSizedBidiNonCommonView>);
 static_assert(!std::ranges::random_access_range<NonSimpleSizedBidiNonCommonView>);
 static_assert(!std::ranges::common_range<NonSimpleSizedBidiNonCommonView>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<NonSimpleSizedBidiNonCommonView>);
+static_assert(!simple_view<NonSimpleSizedBidiNonCommonView>);
 
 namespace adltest{
 struct iter_move_swap_iterator {
diff --git a/libcxx/test/support/test_range.h b/libcxx/test/support/test_range.h
index 3f03b4d391b8c4..f4d8cf20354a77 100644
--- a/libcxx/test/support/test_range.h
+++ b/libcxx/test/support/test_range.h
@@ -11,6 +11,7 @@
 
 #include <iterator>
 #include <ranges>
+#include <__concepts/same_as.h>
 
 #include "test_iterators.h"
 
@@ -82,4 +83,10 @@ using NonBorrowedView = std::ranges::single_view<int>;
 static_assert(std::ranges::view<NonBorrowedView>);
 static_assert(!std::ranges::borrowed_range<NonBorrowedView>);
 
+template <class Range>
+concept simple_view =
+    std::ranges::view<Range> && std::ranges::range<const Range> &&
+    std::same_as<std::ranges::iterator_t<Range>, std::ranges::iterator_t<const Range>> &&
+    std::same_as<std::ranges::sentinel_t<Range>, std::ranges::sentinel_t<const Range>>;
+
 #endif // LIBCXX_TEST_SUPPORT_TEST_RANGE_H

>From 7fa5204c3f44b8d6f63345f516b2983ac240e6b9 Mon Sep 17 00:00:00 2001
From: Will Hawkins <hawkinsw at obs.cr>
Date: Mon, 8 Jan 2024 16:34:25 -0500
Subject: [PATCH 2/4] fixup! [libc++][NFC] Create and use test-defined
 simple_view concept

Address review feedback.
---
 .../range.adaptors/range.take/begin.pass.cpp  |  2 +-
 .../ranges/simple_view_consistent.pass.cpp    | 60 +++++++++++++++++++
 libcxx/test/support/test_range.h              |  2 +-
 3 files changed, 62 insertions(+), 2 deletions(-)
 create mode 100644 libcxx/test/std/ranges/simple_view_consistent.pass.cpp

diff --git a/libcxx/test/std/ranges/range.adaptors/range.take/begin.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.take/begin.pass.cpp
index 0946542fdca9ed..1873481d732253 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.take/begin.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.take/begin.pass.cpp
@@ -69,7 +69,7 @@ constexpr bool test() {
     ASSERT_SAME_TYPE(decltype(tv.begin()), std::counted_iterator<int*>);
   }
 
-  // simple_view<V> && sized_range<V> && !size_range<!V>
+  // simple-view<V> && sized_range<V> && !size_range<!V>
   {
     std::ranges::take_view<NonCommonSimpleView> tv{};
     ASSERT_SAME_TYPE(decltype(tv.begin()), std::counted_iterator<int*>);
diff --git a/libcxx/test/std/ranges/simple_view_consistent.pass.cpp b/libcxx/test/std/ranges/simple_view_consistent.pass.cpp
new file mode 100644
index 00000000000000..1c12df4c99d5a9
--- /dev/null
+++ b/libcxx/test/std/ranges/simple_view_consistent.pass.cpp
@@ -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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// simple_view
+
+#include <ranges>
+
+#include "test_iterators.h"
+#include "test_range.h"
+
+struct test_simple_view : std::ranges::view_base {
+  constexpr int* begin() const { return nullptr; }
+  constexpr int* end() const { return nullptr; }
+};
+
+struct test_different_sentinel : std::ranges::view_base {
+  constexpr int* begin() const { return nullptr; }
+  constexpr int* end() { return nullptr; }
+  constexpr sentinel_wrapper<int*> end() const { return sentinel_wrapper<int*>{nullptr}; }
+};
+
+struct test_different_begin : std::ranges::view_base {
+  constexpr int* begin() { return nullptr; }
+  constexpr double* begin() const { return nullptr; }
+  constexpr int* end() const { return nullptr; }
+};
+
+struct test_non_view {
+  constexpr int* begin() const { return nullptr; }
+  constexpr int* end() const { return nullptr; }
+};
+
+struct test_view_non_const_range : std::ranges::view_base {
+  constexpr int* begin() { return nullptr; }
+  constexpr int* end() { return nullptr; }
+};
+
+static_assert(simple_view<test_simple_view>);
+LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<test_simple_view>);
+
+static_assert(!simple_view<test_different_sentinel>);
+LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<test_different_sentinel>);
+
+static_assert(!simple_view<test_different_begin>);
+LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<test_different_begin>);
+
+static_assert(!simple_view<test_non_view>);
+LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<test_non_view>);
+
+static_assert(!simple_view<test_view_non_const_range>);
+LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<test_view_non_const_range>);
+
+int main(int, char**) { return 0; }
diff --git a/libcxx/test/support/test_range.h b/libcxx/test/support/test_range.h
index f4d8cf20354a77..6061f710a26363 100644
--- a/libcxx/test/support/test_range.h
+++ b/libcxx/test/support/test_range.h
@@ -9,9 +9,9 @@
 #ifndef LIBCXX_TEST_SUPPORT_TEST_RANGE_H
 #define LIBCXX_TEST_SUPPORT_TEST_RANGE_H
 
+#include <concepts>
 #include <iterator>
 #include <ranges>
-#include <__concepts/same_as.h>
 
 #include "test_iterators.h"
 

>From 6f0225364ef584be8069087968e3b9cacade786b Mon Sep 17 00:00:00 2001
From: Will Hawkins <hawkinsw at obs.cr>
Date: Mon, 8 Jan 2024 21:04:30 -0500
Subject: [PATCH 3/4] fixup! [libc++][NFC] Create and use test-defined
 simple_view concept

Use existing avenue for testing of the new simple_view concept.
---
 .../simple_view.compile.pass.cpp              |  7 +++
 .../ranges/simple_view_consistent.pass.cpp    | 60 -------------------
 2 files changed, 7 insertions(+), 60 deletions(-)
 delete mode 100644 libcxx/test/std/ranges/simple_view_consistent.pass.cpp

diff --git a/libcxx/test/libcxx/ranges/range.utility.helpers/simple_view.compile.pass.cpp b/libcxx/test/libcxx/ranges/range.utility.helpers/simple_view.compile.pass.cpp
index ce8cd112468c15..2f117c387c4e5e 100644
--- a/libcxx/test/libcxx/ranges/range.utility.helpers/simple_view.compile.pass.cpp
+++ b/libcxx/test/libcxx/ranges/range.utility.helpers/simple_view.compile.pass.cpp
@@ -14,6 +14,7 @@
 
 #include "test_macros.h"
 #include "test_iterators.h"
+#include "test_range.h"
 
 struct SimpleView : std::ranges::view_base {
   int *begin() const;
@@ -48,3 +49,9 @@ static_assert(!std::ranges::__simple_view<WrongConstView>);
 static_assert(!std::ranges::__simple_view<NoConstView>);
 static_assert( std::ranges::__simple_view<DifferentSentinel>);
 static_assert(!std::ranges::__simple_view<WrongConstSentinel>);
+
+static_assert( simple_view<SimpleView>);
+static_assert(!simple_view<WrongConstView>);
+static_assert(!simple_view<NoConstView>);
+static_assert( simple_view<DifferentSentinel>);
+static_assert(!simple_view<WrongConstSentinel>);
diff --git a/libcxx/test/std/ranges/simple_view_consistent.pass.cpp b/libcxx/test/std/ranges/simple_view_consistent.pass.cpp
deleted file mode 100644
index 1c12df4c99d5a9..00000000000000
--- a/libcxx/test/std/ranges/simple_view_consistent.pass.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
-
-// simple_view
-
-#include <ranges>
-
-#include "test_iterators.h"
-#include "test_range.h"
-
-struct test_simple_view : std::ranges::view_base {
-  constexpr int* begin() const { return nullptr; }
-  constexpr int* end() const { return nullptr; }
-};
-
-struct test_different_sentinel : std::ranges::view_base {
-  constexpr int* begin() const { return nullptr; }
-  constexpr int* end() { return nullptr; }
-  constexpr sentinel_wrapper<int*> end() const { return sentinel_wrapper<int*>{nullptr}; }
-};
-
-struct test_different_begin : std::ranges::view_base {
-  constexpr int* begin() { return nullptr; }
-  constexpr double* begin() const { return nullptr; }
-  constexpr int* end() const { return nullptr; }
-};
-
-struct test_non_view {
-  constexpr int* begin() const { return nullptr; }
-  constexpr int* end() const { return nullptr; }
-};
-
-struct test_view_non_const_range : std::ranges::view_base {
-  constexpr int* begin() { return nullptr; }
-  constexpr int* end() { return nullptr; }
-};
-
-static_assert(simple_view<test_simple_view>);
-LIBCPP_STATIC_ASSERT(std::ranges::__simple_view<test_simple_view>);
-
-static_assert(!simple_view<test_different_sentinel>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<test_different_sentinel>);
-
-static_assert(!simple_view<test_different_begin>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<test_different_begin>);
-
-static_assert(!simple_view<test_non_view>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<test_non_view>);
-
-static_assert(!simple_view<test_view_non_const_range>);
-LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view<test_view_non_const_range>);
-
-int main(int, char**) { return 0; }

>From ba3dd6c69747467347e19ff682d44fbda8cb2d48 Mon Sep 17 00:00:00 2001
From: Will Hawkins <hawkinsw at obs.cr>
Date: Mon, 8 Jan 2024 22:33:34 -0500
Subject: [PATCH 4/4] fixup! [libc++][NFC] Create and use test-defined
 simple_view concept

Make clang-format happy.
---
 .../ranges/range.utility.helpers/simple_view.compile.pass.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libcxx/test/libcxx/ranges/range.utility.helpers/simple_view.compile.pass.cpp b/libcxx/test/libcxx/ranges/range.utility.helpers/simple_view.compile.pass.cpp
index 2f117c387c4e5e..a58f74c3b591f1 100644
--- a/libcxx/test/libcxx/ranges/range.utility.helpers/simple_view.compile.pass.cpp
+++ b/libcxx/test/libcxx/ranges/range.utility.helpers/simple_view.compile.pass.cpp
@@ -50,8 +50,8 @@ static_assert(!std::ranges::__simple_view<NoConstView>);
 static_assert( std::ranges::__simple_view<DifferentSentinel>);
 static_assert(!std::ranges::__simple_view<WrongConstSentinel>);
 
-static_assert( simple_view<SimpleView>);
+static_assert(simple_view<SimpleView>);
 static_assert(!simple_view<WrongConstView>);
 static_assert(!simple_view<NoConstView>);
-static_assert( simple_view<DifferentSentinel>);
+static_assert(simple_view<DifferentSentinel>);
 static_assert(!simple_view<WrongConstSentinel>);



More information about the libcxx-commits mailing list