match.pd: Fix indefinite recursion during exp-log transformations [PR118490]
[gcc.git] / libstdc++-v3 / testsuite / 25_algorithms / is_permutation / lwg3560.cc
blobf9469b08a2f5ad2df8f3f792734d889614ac62fb
1 // { dg-do run { target c++20 } }
3 // LWG 3560. ranges::equal and ranges::is_permutation should short-circuit
4 // for sized_ranges
6 #include <algorithm>
7 #include <testsuite_iterators.h>
8 #include <testsuite_hooks.h>
10 struct X
12 // Any equality comparison will cause the test to fail.
13 bool operator==(const X&) const { VERIFY(false); }
16 void
17 test_std_is_permutation()
19 X vals[3];
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(),
26 pred) );
29 void
30 test_std_ranges_is_permutation()
32 X vals[3];
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(),
39 r2.begin(), r2.end(),
40 {}, proj, proj) );
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) );
47 int main()
49 test_std_is_permutation();
50 test_std_ranges_is_permutation();