1 // Copyright (C) 2020-2021 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-options "-std=gnu++2a" }
19 // { dg-do run { target c++2a } }
22 #include <testsuite_hooks.h>
23 #include <testsuite_iterators.h>
25 using __gnu_test::test_container
;
26 using __gnu_test::forward_iterator_wrapper
;
27 using __gnu_test::bidirectional_iterator_wrapper
;
28 using __gnu_test::random_access_iterator_wrapper
;
33 bool moved_from
= false;
42 X
& operator=(const X
&) = delete;
47 *this = std::move(other
);
54 other
.moved_from
= true;
60 template<int N
, template<typename
> typename Wrapper
>
64 for (int n
= 0; n
< N
+5; n
++)
67 for (int i
= 0; i
< N
; i
++)
69 test_container
<X
, Wrapper
> cx(x
);
70 auto out
= std::shift_left(cx
.begin(), cx
.end(), n
);
73 VERIFY( out
.ptr
== x
+(N
-n
) );
74 for (int i
= 0; i
< N
-n
; i
++)
76 VERIFY( x
[i
].a
== n
+i
);
77 VERIFY( !x
[i
].moved_from
);
79 for (int i
= std::max(n
, N
-n
); i
< N
; i
++)
80 VERIFY( x
[i
].moved_from
);
84 VERIFY( out
.ptr
== x
);
85 for (int i
= 0; i
< N
; i
++)
87 VERIFY( x
[i
].a
== i
);
88 VERIFY( !x
[i
].moved_from
);
97 test01
<23, forward_iterator_wrapper
>();
98 test01
<23, bidirectional_iterator_wrapper
>();
99 test01
<23, random_access_iterator_wrapper
>();
101 test01
<24, forward_iterator_wrapper
>();
102 test01
<24, bidirectional_iterator_wrapper
>();
103 test01
<24, random_access_iterator_wrapper
>();