1 // Copyright (C) 2020-2024 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/>.
21 #include <testsuite_hooks.h>
26 volatile int i
[2] = { 1, 2 };
27 volatile int j
[2] = { 0, 0 };
31 VERIFY( j
[0] == 1 && j
[1] == 2 );
33 VERIFY( k
[0] == 1 && k
[1] == 2 );
34 std::copy(k
+1, k
+2, i
);
37 const volatile int* cj
= j
;
38 std::copy(cj
, cj
+2, i
);
39 VERIFY( i
[0] == 1 && i
[1] == 2 );
40 std::copy(cj
+1, cj
+2, k
);
43 std::copy(ck
, ck
+2, i
);
44 VERIFY( i
[0] == 2 && i
[1] == 2 );
50 #if __cplusplus > 201703L
51 volatile int i
[2] = { 1, 2 };
52 volatile int j
[2] = { 0, 0 };
55 std::ranges::copy(i
, i
+2, j
);
56 VERIFY( j
[0] == 1 && j
[1] == 2 );
57 std::ranges::copy(i
, i
+2, k
);
58 VERIFY( k
[0] == 1 && k
[1] == 2 );
59 std::ranges::copy(k
+1, k
+2, i
);
62 const volatile int* cj
= j
;
63 std::ranges::copy(cj
, cj
+2, i
);
64 VERIFY( i
[0] == 1 && i
[1] == 2 );
65 std::ranges::copy(cj
+1, cj
+2, k
);
68 std::ranges::copy(ck
, ck
+2, i
);
69 VERIFY( i
[0] == 2 && i
[1] == 2 );