1 // { dg-do run { target c++20 } }
3 // LWG 3560. ranges::equal and ranges::is_permutation should short-circuit
7 #include <testsuite_iterators.h>
8 #include <testsuite_hooks.h>
12 // Any equality comparison will cause the test to fail.
13 bool operator==(const X
&) const { VERIFY(false); }
17 test_std_is_permutation()
20 __gnu_test::random_access_container
<X
> r1(vals
, vals
+3);
21 __gnu_test::random_access_container
<X
> r2(vals
, vals
+2);
22 VERIFY( ! std::is_permutation(r1
.begin(), r1
.end(), r2
.begin(), r2
.end()) );
24 std::ranges::equal_to pred
;
25 VERIFY( ! std::is_permutation(r1
.begin(), r1
.end(), r2
.begin(), r2
.end(),
30 test_std_ranges_is_permutation()
33 __gnu_test::test_random_access_range
<X
> r1(vals
, vals
+3);
34 __gnu_test::test_random_access_range
<X
> r2(vals
, vals
+2);
36 // Any application of the projection will cause the test to fail.
37 auto proj
= [](const X
&) -> const X
& { VERIFY(false); };
38 VERIFY( ! std::ranges::is_permutation(r1
.begin(), r1
.end(),
42 __gnu_test::test_forward_sized_range
<X
> r3(vals
, vals
+3);
43 __gnu_test::test_forward_sized_range
<X
> r4(vals
, vals
+2);
44 VERIFY( ! std::ranges::is_permutation(r3
, r4
, {}, proj
, proj
) );
49 test_std_is_permutation();
50 test_std_ranges_is_permutation();