1 // Copyright (C) 2020-2025 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-do run { target c++20 } }
21 #include <testsuite_hooks.h>
22 #include <testsuite_iterators.h>
24 using __gnu_test::test_container
;
25 using __gnu_test::test_range
;
26 using __gnu_test::forward_iterator_wrapper
;
27 using __gnu_test::random_access_iterator_wrapper
;
29 namespace ranges
= std::ranges
;
38 operator==(const X
& lhs
, const X
& rhs
)
40 return lhs
.i
== rhs
.i
;
44 static_assert(!std::is_trivially_default_constructible_v
<X
>);
46 template<template<typename
, template<typename
> typename
> typename container
,
47 template<typename
> typename wrapper
,
52 for (int a
= 0; a
<= 7; a
++)
54 T x
[] = {1, 2, 3, 4, 5, 6, 7};
56 container
<T
, wrapper
> rx(x
), rw(w
);
57 auto i
= ranges::begin(rx
);
59 auto [in
,out
] = ranges::rotate_copy(rx
, i
, ranges::begin(rw
));
60 VERIFY( in
== ranges::end(rx
) );
61 VERIFY( out
== ranges::end(rw
) );
62 for (int k
= 0; k
< 7; k
++)
63 VERIFY( w
[k
] == (k
+a
)%7 + 1 );
70 const int x
[] = {1, 2, 3, 4};
72 const int y
[] = { 2, 3, 1};
73 auto [in
,out
] = ranges::rotate_copy(x
, x
+1, x
+3, w
);
76 && ranges::equal(w
, y
));
82 test01
<test_container
, forward_iterator_wrapper
>();
83 test01
<test_range
, forward_iterator_wrapper
>();
85 test01
<test_container
, random_access_iterator_wrapper
>();
86 test01
<test_range
, random_access_iterator_wrapper
>();
88 test01
<test_container
, random_access_iterator_wrapper
, X
>();
89 test01
<test_range
, random_access_iterator_wrapper
, X
>();
91 static_assert(test02());