[libcxx-commits] [PATCH] D116808: fix __simple_view concept in std::ranges

Hui via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jan 7 07:43:21 PST 2022


huixie90 updated this revision to Diff 398144.
huixie90 added a comment.

Updating D116808 <https://reviews.llvm.org/D116808>: fix __simple_view concept in std::ranges

revert formatting and add unit test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116808/new/

https://reviews.llvm.org/D116808

Files:
  libcxx/include/__ranges/concepts.h
  libcxx/test/libcxx/ranges/range.utility.helpers/simple_view.compile.pass.cpp


Index: libcxx/test/libcxx/ranges/range.utility.helpers/simple_view.compile.pass.cpp
===================================================================
--- libcxx/test/libcxx/ranges/range.utility.helpers/simple_view.compile.pass.cpp
+++ libcxx/test/libcxx/ranges/range.utility.helpers/simple_view.compile.pass.cpp
@@ -34,12 +34,19 @@
   int *end();
 };
 
-struct DifferentSentinel : std::ranges::view_base {
+struct WithSentinel : std::ranges::view_base {
   int *begin() const;
   sentinel_wrapper<int*> end() const;
 };
 
+struct WrongConstSentinel : std::ranges::view_base {
+  int *begin() const;
+  sentinel_wrapper<int*> end();
+  sentinel_wrapper<const int*> end() const;
+};
+
 static_assert( std::ranges::__simple_view<SimpleView>);
 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<WithSentinel>);
+static_assert(!std::ranges::__simple_view<WrongConstSentinel>);
Index: libcxx/include/__ranges/concepts.h
===================================================================
--- libcxx/include/__ranges/concepts.h
+++ libcxx/include/__ranges/concepts.h
@@ -80,11 +80,11 @@
     movable<_Tp> &&
     enable_view<_Tp>;
 
-  template<class _Range>
-  concept __simple_view =
-    view<_Range> && range<const _Range> &&
-    same_as<iterator_t<_Range>, iterator_t<const _Range>> &&
-    same_as<sentinel_t<_Range>, iterator_t<const _Range>>;
+  template <class _Range>
+  concept __simple_view = 
+      view<_Range> && range<const _Range> &&
+      same_as<iterator_t<_Range>, iterator_t<const _Range>> && 
+      same_as<sentinel_t<_Range>, sentinel_t<const _Range>>;
 
   // [range.refinements], other range refinements
   template <class _Rp, class _Tp>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116808.398144.patch
Type: text/x-patch
Size: 1837 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220107/f765b1ff/attachment.bin>


More information about the libcxx-commits mailing list