[libcxx-commits] [libcxx] 8615ce2 - [libc++][test] Adjust move_iterator tests to allow C++20

Casey Carter via libcxx-commits libcxx-commits at lists.llvm.org
Thu May 7 09:59:50 PDT 2020


Author: Casey Carter
Date: 2020-05-07T09:58:13-07:00
New Revision: 8615ce246d1c3424cd5958592ba2779aa7d37535

URL: https://github.com/llvm/llvm-project/commit/8615ce246d1c3424cd5958592ba2779aa7d37535
DIFF: https://github.com/llvm/llvm-project/commit/8615ce246d1c3424cd5958592ba2779aa7d37535.diff

LOG: [libc++][test] Adjust move_iterator tests to allow C++20

These tests fail due to a couple of changes to `move_iterator` for C++20:

* `move_iterator<I>::operator++(int)` returns `void` in C++20 if `I` doesn't model `forward_iterator`.

* `move_iterator<I>::reference` is calculated in C++20, so `I` must actually have an `operator*() const`.

Differential Revision: https://reviews.llvm.org/D79343

Added: 
    

Modified: 
    libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
    libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp b/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
index 50597a54b0bf..e2269073aef4 100644
--- a/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
+++ b/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
@@ -16,10 +16,20 @@
 
 #include <iterator>
 #include <cassert>
+#include <utility>
 
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#if TEST_STD_VER > 17
+template <class It>
+void test_single_pass(It i, It x) {
+  std::move_iterator<It> r(std::move(i));
+  r++;
+  assert(std::move(r).base() == x);
+}
+#endif
+
 template <class It>
 void
 test(It i, It x)
@@ -33,7 +43,11 @@ test(It i, It x)
 int main(int, char**)
 {
     char s[] = "123";
+#if TEST_STD_VER > 17
+    test_single_pass(input_iterator<char*>(s), input_iterator<char*>(s + 1));
+#else
     test(input_iterator<char*>(s), input_iterator<char*>(s+1));
+#endif
     test(forward_iterator<char*>(s), forward_iterator<char*>(s+1));
     test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1));
     test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1));

diff  --git a/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp b/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
index 905952f42bd4..25dc47e7e7b6 100644
--- a/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
+++ b/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
@@ -35,6 +35,8 @@ struct DummyIt {
   typedef std::ptr
diff _t 
diff erence_type;
   typedef ValueType* pointer;
   typedef Reference reference;
+
+  Reference operator*() const;
 };
 
 template <class It>


        


More information about the libcxx-commits mailing list