1 // { dg-do run { target c++23 } }
4 #include <testsuite_hooks.h>
5 #include <testsuite_iterators.h>
7 #if __cpp_lib_ranges_contains != 202207L
8 # error "Feature-test macro __cpp_lib_ranges_contains has wrong value in <algorithm>"
11 namespace ranges
= std::ranges
;
17 using to_input
= __gnu_test::test_input_range
<int>;
18 VERIFY( ranges::contains(to_input(x
), 1) );
19 VERIFY( ranges::contains(to_input(x
), 2) );
20 VERIFY( ranges::contains(to_input(x
), 3) );
21 VERIFY( !ranges::contains(to_input(x
), 4) );
22 VERIFY( !ranges::contains(x
, x
+2, 3) );
23 auto neg
= [](int n
) { return -n
; };
24 VERIFY( ranges::contains(to_input(x
), -1, neg
) );
25 VERIFY( ranges::contains(to_input(x
), -2, neg
) );
26 VERIFY( ranges::contains(to_input(x
), -3, neg
) );
27 VERIFY( !ranges::contains(to_input(x
), -4, neg
) );
29 VERIFY( !ranges::contains(x
, x
+2, -3, neg
) );