1 // Copyright (C) 2020-2024 Free Software Foundation, Inc.
2 // This file is part of the GNU ISO C++ Library. This library is free
3 // software; you can redistribute it and/or modify it under the
4 // terms of the GNU General Public License as published by the
5 // Free Software Foundation; either version 3, or (at your option)
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
13 // You should have received a copy of the GNU General Public License along
14 // with this library; see the file COPYING3. If not see
15 // <http://www.gnu.org/licenses/>.
17 // { dg-do run { target c++20 } }
28 #include <testsuite_hooks.h>
29 #include <testsuite_iterators.h>
31 using __gnu_test::test_range
;
32 using __gnu_test::input_iterator_wrapper_nocopy
;
34 namespace ranges
= std::ranges
;
44 static inline int count
= 0;
50 for (int k
= 0; k
< 3; k
++)
52 constexpr int size
= 1024;
53 auto buffer
= std::unique_ptr
<char[]>(new char[sizeof(X
)*size
]);
54 std::span
<X
> rx((X
*)buffer
.get(), size
);
56 ranges::uninitialized_default_construct(rx
);
57 VERIFY( X::count
== size
);
61 i
= ranges::destroy(rx
);
63 i
= ranges::destroy(rx
.begin(), rx
.end());
65 i
= ranges::destroy_n(rx
.begin(), size
);
69 VERIFY( i
== rx
.end() );
70 VERIFY( X::count
== 0 );
80 test_range
<int, input_iterator_wrapper_nocopy
> rx(x
);
82 ranges::destroy_n(rx
.begin(), 3);