[libcxx-commits] [PATCH] D105894: Revert "[libc++] NFCI: Remove code duplication and obsolete declarations in wrap_iter"

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 13 13:45:04 PDT 2021


ldionne updated this revision to Diff 358419.
ldionne added a comment.

Add test to trigger the std::rel_ops failure.

Arthur kindly suggested to me that he could handle finding the solution, and I will take on that offer so I can keep reviewing ranges stuff. Feel free to commandeer. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105894

Files:
  libcxx/test/libcxx/containers/iterator.rel_ops.compile.pass.cpp


Index: libcxx/test/libcxx/containers/iterator.rel_ops.compile.pass.cpp
===================================================================
--- /dev/null
+++ libcxx/test/libcxx/containers/iterator.rel_ops.compile.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// Make sure the various container's iterators are not broken by the use of `std::rel_ops`.
+
+#include <utility> // for std::rel_ops
+
+#include <array>
+#include <deque>
+#include <forward_list>
+#include <list>
+#include <map>
+#include <set>
+#include <unordered_map>
+#include <unordered_set>
+#include <vector>
+
+using namespace std::rel_ops;
+
+template<class Container>
+void test() {
+    Container const c = Container();
+    typename Container::const_iterator it1 = c.end(), it2 = c.end();
+    (void)(it1 == it2);
+    (void)(it1 != it2);
+}
+
+template<class Container>
+void test_random_access() {
+    Container const c = Container();
+    typename Container::const_iterator it1 = c.end(), it2 = c.end();
+    (void)(it1 == it2);
+    (void)(it1 != it2);
+    (void)(it1 < it2);
+    (void)(it1 > it2);
+    (void)(it1 <= it2);
+    (void)(it1 >= it2);
+}
+
+template void test_random_access<std::array<int, 10> >();
+template void test_random_access<std::deque<int> >();
+template void test<std::forward_list<int> >();
+template void test<std::list<int> >();
+template void test<std::map<int, int> >();
+template void test<std::multimap<int, int> >();
+template void test<std::multiset<int> >();
+template void test<std::set<int> >();
+template void test<std::unordered_map<int, int> >();
+template void test<std::unordered_multimap<int, int> >();
+template void test<std::unordered_multiset<int> >();
+template void test<std::unordered_set<int> >();
+template void test_random_access<std::vector<int> >();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105894.358419.patch
Type: text/x-patch
Size: 2141 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210713/eec26961/attachment-0001.bin>


More information about the libcxx-commits mailing list