| 1 |
// { dg-do run { target c++23 } } |
| 2 |
|
| 3 |
#include <numeric> |
| 4 |
#include <testsuite_hooks.h> |
| 5 |
#include <testsuite_iterators.h> |
| 6 |
|
| 7 |
#if __cpp_lib_ranges_iota != 202202L |
| 8 |
# error "Feature-test macro __cpp_lib_ranges_iota has wrong value in <numeric>" |
| 9 |
#endif |
| 10 |
|
| 11 |
namespace ranges = std::ranges; |
| 12 |
|
| 13 |
void |
| 14 |
test01() |
| 15 |
{ |
| 16 |
int x[3] = {}; |
| 17 |
__gnu_test::test_output_range<int> rx(x); |
| 18 |
auto r0 = ranges::iota(rx, 0); |
| 19 |
VERIFY( r0.out.ptr == x+3 ); |
| 20 |
VERIFY( r0.value == 3 ); |
| 21 |
VERIFY( ranges::equal(x, (int[]){0,1,2}) ); |
| 22 |
auto r1 = ranges::iota(x, x+2, 5); |
| 23 |
VERIFY( r1.out == x+2 ); |
| 24 |
VERIFY( r1.value == 7 ); |
| 25 |
VERIFY( ranges::equal(x, (int[]){5,6,2}) ); |
| 26 |
} |
| 27 |
|
| 28 |
int |
| 29 |
main() |
| 30 |
{ |
| 31 |
test01(); |
| 32 |
} |