[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / algorithms / robust_against_adl.pass.cpp
bloba9ea46a50c9077e723b3fa66e1fa6bdaff703e0f
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: clang-8
10 // UNSUPPORTED: c++03
12 // <algorithm>
14 #include <algorithm>
15 #include <functional>
17 #include "test_macros.h"
19 struct Incomplete;
20 template<class T> struct Holder { T t; };
22 template<class>
23 struct Intable {
24 TEST_CONSTEXPR operator int() const { return 1; }
27 struct Tester {
28 using Element = Holder<Incomplete>*;
29 Element data[10];
32 TEST_CONSTEXPR_CXX20 bool test()
34 Tester t {};
35 Tester u {};
36 Tester::Element value = nullptr;
37 Intable<Tester::Element> count;
39 // THESE RELY ON ADL SWAP IN PRACTICE:
40 // swap_ranges, iter_swap, reverse, rotate, partition
41 // sort, nth_element
42 // pop_heap, sort_heap, partial_sort, partial_sort_copy
43 // next_permutation, prev_permutation
44 // stable_partition, stable_sort, inplace_merge
45 // THESE RELY ON ADL SWAP IN THEORY:
46 // push_heap, make_heap
48 (void)std::all_of(t.data, t.data+10, [](void*){ return true; });
49 (void)std::any_of(t.data, t.data+10, [](void*){ return true; });
50 (void)std::copy(t.data, t.data+10, u.data);
51 (void)std::copy_n(t.data, count, u.data);
52 (void)std::copy_backward(t.data, t.data+10, u.data+10);
53 (void)std::count(t.data, t.data+10, value);
54 (void)std::count_if(t.data, t.data+10, [](void*){ return true; });
55 (void)std::distance(t.data, t.data+10);
56 (void)std::fill(t.data, t.data+10, value);
57 (void)std::fill_n(t.data, count, value);
58 (void)std::find_if(t.data, t.data+10, [](void*){ return true; });
59 (void)std::find_if_not(t.data, t.data+10, [](void*){ return true; });
60 (void)std::for_each(t.data, t.data+10, [](void*){});
61 #if TEST_STD_VER >= 17
62 (void)std::for_each_n(t.data, count, [](void*){});
63 #endif
64 (void)std::generate(t.data, t.data+10, [](){ return nullptr; });
65 (void)std::generate_n(t.data, count, [](){ return nullptr; });
66 (void)std::is_partitioned(t.data, t.data+10, [](void*){ return true; });
67 (void)std::move(t.data, t.data+10, u.data);
68 (void)std::move_backward(t.data, t.data+10, u.data+10);
69 (void)std::none_of(t.data, t.data+10, [](void*){ return true; });
70 (void)std::partition_copy(t.data, t.data+5, u.data, u.data+5, [](void*){ return true; });
71 (void)std::partition_point(t.data, t.data+10, [](void*){ return true; });
72 (void)std::remove(t.data, t.data+10, value);
73 (void)std::remove_copy(t.data, t.data+10, u.data, value);
74 (void)std::remove_copy_if(t.data, t.data+10, u.data, [](void*){ return true; });
75 (void)std::remove_if(t.data, t.data+10, [](void*){ return true; });
76 (void)std::replace(t.data, t.data+10, value, value);
77 (void)std::replace_copy(t.data, t.data+10, u.data, value, value);
78 (void)std::replace_copy_if(t.data, t.data+10, u.data, [](void*){ return true; }, value);
79 (void)std::replace_if(t.data, t.data+10, [](void*){ return true; }, value);
80 (void)std::reverse_copy(t.data, t.data+10, u.data);
81 (void)std::rotate_copy(t.data, t.data+5, t.data+10, u.data);
82 // TODO: shift_left
83 // TODO: shift_right
84 (void)std::transform(t.data, t.data+10, u.data, [](void*){ return nullptr; });
86 // WITHOUT COMPARATORS
87 (void)std::adjacent_find(t.data, t.data+10);
88 (void)std::binary_search(t.data, t.data+10, t.data[5]);
89 (void)std::equal(t.data, t.data+10, u.data);
90 (void)std::equal_range(t.data, t.data+10, t.data[5]);
91 (void)std::find_end(t.data, t.data+10, u.data, u.data+5);
92 (void)std::includes(t.data, t.data+10, u.data, u.data+10);
93 (void)std::is_heap(t.data, t.data+10);
94 (void)std::is_heap_until(t.data, t.data+10);
95 (void)std::is_permutation(t.data, t.data+10, u.data);
96 (void)std::is_sorted(t.data, t.data+10);
97 (void)std::is_sorted_until(t.data, t.data+10);
98 (void)std::lexicographical_compare(t.data, t.data+10, u.data, u.data+10);
99 // TODO: lexicographical_compare_three_way
100 (void)std::lower_bound(t.data, t.data+10, t.data[5]);
101 (void)std::max(value, value);
102 (void)std::max({ value, value });
103 (void)std::max_element(t.data, t.data+10);
104 (void)std::merge(t.data, t.data+5, t.data+5, t.data+10, u.data);
105 (void)std::min(value, value);
106 (void)std::min({ value, value });
107 (void)std::min_element(t.data, t.data+10);
108 (void)std::minmax(value, value);
109 (void)std::minmax({ value, value });
110 (void)std::minmax_element(t.data, t.data+10);
111 (void)std::mismatch(t.data, t.data+10, u.data);
112 (void)std::search(t.data, t.data+10, u.data, u.data+5);
113 (void)std::search_n(t.data, t.data+10, count, value);
114 (void)std::set_difference(t.data, t.data+5, t.data+5, t.data+10, u.data);
115 (void)std::set_intersection(t.data, t.data+5, t.data+5, t.data+10, u.data);
116 (void)std::set_symmetric_difference(t.data, t.data+5, t.data+5, t.data+10, u.data);
117 (void)std::set_union(t.data, t.data+5, t.data+5, t.data+10, u.data);
118 (void)std::unique(t.data, t.data+10);
119 (void)std::unique_copy(t.data, t.data+10, u.data);
120 (void)std::upper_bound(t.data, t.data+10, t.data[5]);
121 #if TEST_STD_VER >= 14
122 (void)std::equal(t.data, t.data+10, u.data, u.data+10);
123 (void)std::is_permutation(t.data, t.data+10, u.data, u.data+10);
124 (void)std::mismatch(t.data, t.data+10, u.data, u.data+10);
125 #endif
126 #if TEST_STD_VER >= 20
127 (void)std::clamp(value, value, value);
128 #endif
130 // WITH COMPARATORS
131 (void)std::adjacent_find(t.data, t.data+10, std::equal_to<void*>());
132 (void)std::binary_search(t.data, t.data+10, value, std::less<void*>());
133 (void)std::equal(t.data, t.data+10, u.data, std::equal_to<void*>());
134 (void)std::equal_range(t.data, t.data+10, value, std::less<void*>());
135 (void)std::find_end(t.data, t.data+10, u.data, u.data+5, std::equal_to<void*>());
136 (void)std::includes(t.data, t.data+10, u.data, u.data+10, std::less<void*>());
137 (void)std::is_heap(t.data, t.data+10, std::less<void*>());
138 (void)std::is_heap_until(t.data, t.data+10, std::less<void*>());
139 (void)std::is_permutation(t.data, t.data+10, u.data, std::equal_to<void*>());
140 (void)std::is_sorted(t.data, t.data+10, std::less<void*>());
141 (void)std::is_sorted_until(t.data, t.data+10, std::less<void*>());
142 (void)std::lexicographical_compare(t.data, t.data+10, u.data, u.data+10, std::less<void*>());
143 // TODO: lexicographical_compare_three_way
144 (void)std::lower_bound(t.data, t.data+10, value, std::less<void*>());
145 (void)std::max(value, value, std::less<void*>());
146 (void)std::max({ value, value }, std::less<void*>());
147 (void)std::max_element(t.data, t.data+10, std::less<void*>());
148 (void)std::merge(t.data, t.data+5, t.data+5, t.data+10, u.data, std::less<void*>());
149 (void)std::min(value, value, std::less<void*>());
150 (void)std::min({ value, value }, std::less<void*>());
151 (void)std::min_element(t.data, t.data+10, std::less<void*>());
152 (void)std::minmax(value, value, std::less<void*>());
153 (void)std::minmax({ value, value }, std::less<void*>());
154 (void)std::minmax_element(t.data, t.data+10, std::less<void*>());
155 (void)std::mismatch(t.data, t.data+10, u.data, std::equal_to<void*>());
156 (void)std::search(t.data, t.data+10, u.data, u.data+5, std::equal_to<void*>());
157 (void)std::search_n(t.data, t.data+10, count, value, std::equal_to<void*>());
158 (void)std::set_difference(t.data, t.data+5, t.data+5, t.data+10, u.data, std::less<void*>());
159 (void)std::set_intersection(t.data, t.data+5, t.data+5, t.data+10, u.data, std::less<void*>());
160 (void)std::set_symmetric_difference(t.data, t.data+5, t.data+5, t.data+10, u.data, std::less<void*>());
161 (void)std::set_union(t.data, t.data+5, t.data+5, t.data+10, u.data, std::less<void*>());
162 (void)std::unique(t.data, t.data+10, std::equal_to<void*>());
163 (void)std::unique_copy(t.data, t.data+10, u.data, std::equal_to<void*>());
164 (void)std::upper_bound(t.data, t.data+10, value, std::less<void*>());
165 #if TEST_STD_VER >= 14
166 (void)std::equal(t.data, t.data+10, u.data, u.data+10, std::equal_to<void*>());
167 (void)std::is_permutation(t.data, t.data+10, u.data, u.data+10, std::equal_to<void*>());
168 (void)std::mismatch(t.data, t.data+10, u.data, u.data+10, std::equal_to<void*>());
169 #endif
170 #if TEST_STD_VER >= 20
171 (void)std::clamp(value, value, value, std::less<void*>());
172 #endif
174 return true;
177 int main(int, char**)
179 test();
180 #if TEST_STD_VER >= 20
181 static_assert(test());
182 #endif
183 return 0;