|
19 | 19 | // constexpr bool ranges::contains(R&& r, const T& value, Proj proj = {}); // since C++23
|
20 | 20 |
|
21 | 21 | #include <algorithm>
|
| 22 | +#include <array> |
22 | 23 | #include <cassert>
|
23 | 24 | #include <list>
|
24 | 25 | #include <ranges>
|
@@ -89,8 +90,8 @@ constexpr void test_iterators() {
|
89 | 90 | }
|
90 | 91 |
|
91 | 92 | { // check that an empty range works
|
92 |
| - ValueT a[] = {}; |
93 |
| - auto whole = std::ranges::subrange(Iter(a), Sent(Iter(a))); |
| 93 | + std::array<ValueT, 0> a = {}; |
| 94 | + auto whole = std::ranges::subrange(Iter(a.data()), Sent(Iter(a.data()))); |
94 | 95 | {
|
95 | 96 | bool ret = std::ranges::contains(whole.begin(), whole.end(), 1);
|
96 | 97 | assert(!ret);
|
@@ -164,7 +165,7 @@ constexpr bool test() {
|
164 | 165 | });
|
165 | 166 | });
|
166 | 167 |
|
167 |
| - { // count invocations of the projection for continuous iterators |
| 168 | + { // count invocations of the projection for contiguous iterators |
168 | 169 | int a[] = {1, 9, 0, 13, 25};
|
169 | 170 | int projection_count = 0;
|
170 | 171 | {
|
@@ -215,22 +216,22 @@ constexpr bool test() {
|
215 | 216 | }
|
216 | 217 | }
|
217 | 218 |
|
218 |
| - { // check invocations of the projection for non-continuous iterators |
| 219 | + { // check invocations of the projection for non-contiguous iterators |
219 | 220 | std::vector<bool> whole{false, false, true, false};
|
220 | 221 | int projection_count = 0;
|
221 | 222 | {
|
222 |
| - bool ret = std::ranges::contains(whole.begin(), whole.end(), true, [&](int i) { |
| 223 | + bool ret = std::ranges::contains(whole.begin(), whole.end(), true, [&](bool b) { |
223 | 224 | ++projection_count;
|
224 |
| - return i; |
| 225 | + return b; |
225 | 226 | });
|
226 | 227 | assert(ret);
|
227 | 228 | assert(projection_count == 3);
|
228 | 229 | projection_count = 0;
|
229 | 230 | }
|
230 | 231 | {
|
231 |
| - bool ret = std::ranges::contains(whole, true, [&](int i) { |
| 232 | + bool ret = std::ranges::contains(whole, true, [&](bool b) { |
232 | 233 | ++projection_count;
|
233 |
| - return i; |
| 234 | + return b; |
234 | 235 | });
|
235 | 236 | assert(ret);
|
236 | 237 | assert(projection_count == 3);
|
|
0 commit comments