[libcxx-commits] [PATCH] D108855: [libcxx] contiguous iterator concept: don't require pointer or complete element types

Joe Loser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Aug 28 20:40:07 PDT 2021


jloser updated this revision to Diff 369296.
jloser added a comment.

Swap pointer and reference types for `wrong_iter_reference_t` so its semantics match its name


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108855

Files:
  libcxx/include/__iterator/concepts.h
  libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.random.access/contiguous_iterator.compile.pass.cpp


Index: libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.random.access/contiguous_iterator.compile.pass.cpp
===================================================================
--- libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.random.access/contiguous_iterator.compile.pass.cpp
+++ libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.random.access/contiguous_iterator.compile.pass.cpp
@@ -101,9 +101,10 @@
 struct wrong_iter_reference_t {
     typedef std::contiguous_iterator_tag    iterator_category;
     typedef short                           value_type;
+    typedef short                           element_type;
     typedef std::ptrdiff_t                  difference_type;
-    typedef int*                            pointer;
-    typedef short&                          reference;
+    typedef short*                          pointer;
+    typedef int&                            reference;
     typedef wrong_iter_reference_t          self;
 
     wrong_iter_reference_t();
@@ -164,7 +165,6 @@
 };
 
 static_assert(std::random_access_iterator<no_element_type>);
-static_assert(!std::contiguous_iterator<no_element_type>);
 
 struct to_address_wrong_return_type {
     typedef std::contiguous_iterator_tag    iterator_category;
Index: libcxx/include/__iterator/concepts.h
===================================================================
--- libcxx/include/__iterator/concepts.h
+++ libcxx/include/__iterator/concepts.h
@@ -171,7 +171,6 @@
   derived_from<_ITER_CONCEPT<_Ip>, contiguous_iterator_tag> &&
   is_lvalue_reference_v<iter_reference_t<_Ip>> &&
   same_as<iter_value_t<_Ip>, remove_cvref_t<iter_reference_t<_Ip>>> &&
-  (is_pointer_v<_Ip> || requires { sizeof(__pointer_traits_element_type<_Ip>); }) &&
   requires(const _Ip& __i) {
     { _VSTD::to_address(__i) } -> same_as<add_pointer_t<iter_reference_t<_Ip>>>;
   };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108855.369296.patch
Type: text/x-patch
Size: 1943 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210829/d7ac469d/attachment.bin>


More information about the libcxx-commits mailing list