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 } }
22 #include <testsuite_hooks.h>
23 #include <testsuite_iterators.h>
25 using __gnu_test::test_container
;
26 using __gnu_test::test_range
;
27 using __gnu_test::input_iterator_wrapper
;
28 using __gnu_test::output_iterator_wrapper
;
29 using __gnu_test::random_access_iterator_wrapper
;
31 namespace ranges
= std::ranges
;
33 template<template<typename
> typename in_wrapper
,
34 template<typename
> typename out_wrapper
>
38 int x
[] = {1,2,3,4,5,6,7};
39 for (int i
= -1; i
<= 7; i
++)
41 test_range
<int, in_wrapper
> rx(x
);
43 test_range
<int, out_wrapper
> rw(w
);
44 ranges::copy_n(rx
.begin(), i
, rw
.begin());
46 VERIFY( ranges::equal(x
, x
+i
, w
, w
+i
) );
55 auto [in
,out
] = ranges::copy_n(x
, 2, y
);
58 && ranges::equal(x
, x
+2, y
, y
+2));
64 test01
<input_iterator_wrapper
,
65 output_iterator_wrapper
>();
66 test01
<random_access_iterator_wrapper
,
67 output_iterator_wrapper
>();
68 test01
<random_access_iterator_wrapper
,
69 random_access_iterator_wrapper
>();
70 static_assert(test02());