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++11 } }
21 #include <testsuite_iterators.h>
26 // Negative sizes should be a no-op
28 const int from
[2] = { 1, 2 };
29 __gnu_test::input_container
<const int> f(from
);
31 std::copy_n(f
.begin(), -1, to
);
33 std::copy_n(from
, -20000, to
); // random access
35 __gnu_test::random_access_container
<const int> f2(from
);
36 std::copy_n(f2
.end(), -1, to
);
37 std::copy_n(f2
.begin(), -1, to
);
42 operator long() const { return 2L; }
44 void operator++() = delete;
45 void operator--() = delete;
46 void operator++(int) = delete;
47 void operator--(int) = delete;
49 template<typename T
> friend void operator+(Size
, T
) = delete;
50 template<typename T
> friend void operator+(T
, Size
) = delete;
51 template<typename T
> friend void operator-(Size
, T
) = delete;
52 template<typename T
> friend void operator-(T
, Size
) = delete;
53 template<typename T
> friend void operator==(Size
, T
) = delete;
54 template<typename T
> friend void operator==(T
, Size
) = delete;
55 template<typename T
> friend void operator!=(Size
, T
) = delete;
56 template<typename T
> friend void operator!=(T
, Size
) = delete;
57 template<typename T
> friend void operator<(Size
, T
) = delete;
58 template<typename T
> friend void operator<(T
, Size
) = delete;
59 template<typename T
> friend void operator<=(Size
, T
) = delete;
60 template<typename T
> friend void operator<=(T
, Size
) = delete;
61 template<typename T
> friend void operator>(Size
, T
) = delete;
62 template<typename T
> friend void operator>(T
, Size
) = delete;
63 template<typename T
> friend void operator>=(Size
, T
) = delete;
64 template<typename T
> friend void operator>=(T
, Size
) = delete;
70 // C++20 only requires that Size is convertible to an integral type,
71 // it doesn't need to support any arithmetic or relational expressions.
73 const int from
[3] = { 1, 2, 3 };
74 __gnu_test::input_container
<const int> f(from
);
76 __gnu_test::output_container
<int> t(to
);
78 std::copy_n(f
.begin(), s
, t
.begin());
83 const int from2
[3] = { 11, 22, 33 };
84 __gnu_test::random_access_container
<const int> f2(from2
);
85 __gnu_test::output_container
<int> t2(to
);
86 std::copy_n(f2
.begin(), s
, t2
.begin());
87 VERIFY( to
[0] == 11 );
88 VERIFY( to
[1] == 22 );