1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // XFAIL: availability-filesystem-missing
11 // Make sure the various containers' iterators are not broken by the use of `std::rel_ops`.
13 #include <utility> // for std::rel_ops
18 #include <forward_list>
23 #include <unordered_map>
24 #include <unordered_set>
27 #include "test_macros.h"
29 #if TEST_STD_VER >= 17
30 #include <string_view>
33 #if TEST_STD_VER >= 20
37 using namespace std::rel_ops
;
39 template<class It
, class ConstIt
>
40 void test_eq(It it
, ConstIt cit
) {
51 template<class It
, class ConstIt
>
52 void test_lt(It it
, ConstIt cit
) {
70 // Test subtraction too, even though std::rel_ops shouldn't affect it.
78 template<class Container
>
80 // There is no need to distinguish "forward" from "bidirectional."
81 // libc++ already can't handle `c.rbegin() >= c.rbegin()` in the
82 // presence of std::rel_ops, and neither can Microsoft nor libstdc++.
85 typename
Container::iterator it
= c
.begin();
86 typename
Container::const_iterator cit
= c
.begin();
90 template<class Container
>
91 void test_random_access() {
93 typename
Container::iterator it
= c
.begin();
94 typename
Container::const_iterator cit
= c
.begin();
99 template void test_random_access
<std::array
<int, 10> >();
100 template void test_random_access
<std::deque
<int> >();
101 template void test_forward
<std::forward_list
<int> >();
102 template void test_forward
<std::list
<int> >();
103 template void test_forward
<std::map
<int, int> >();
104 template void test_forward
<std::multimap
<int, int> >();
105 template void test_forward
<std::multiset
<int> >();
106 template void test_forward
<std::set
<int> >();
107 template void test_random_access
<std::string
>();
108 template void test_forward
<std::unordered_map
<int, int> >();
109 template void test_forward
<std::unordered_multimap
<int, int> >();
110 template void test_forward
<std::unordered_multiset
<int> >();
111 template void test_forward
<std::unordered_set
<int> >();
112 template void test_random_access
<std::vector
<int> >();
114 #if TEST_STD_VER >= 17
115 void test_directory_iterators() {
116 #ifndef TEST_HAS_NO_FILESYSTEM
117 std::filesystem::directory_iterator it
;
120 std::filesystem::recursive_directory_iterator rdit
;
125 template void test_forward
<std::filesystem::path
>();
128 #if TEST_STD_VER >= 17
129 template void test_random_access
<std::string_view
>();
132 #if TEST_STD_VER >= 20
135 std::span
<int>::iterator it
= c
.begin(); // span has no const_iterator