1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <numeric>
10 
11 // template <class ForwardIterator, class T>
12 //     void iota(ForwardIterator first, ForwardIterator last, T value);
13 
14 #include <numeric>
15 #include <cassert>
16 
17 #include "test_macros.h"
18 #include "test_iterators.h"
19 
20 template <class InIter>
21 void
22 test()
23 {
24     int ia[] = {1, 2, 3, 4, 5};
25     int ir[] = {5, 6, 7, 8, 9};
26     const unsigned s = sizeof(ia) / sizeof(ia[0]);
27     std::iota(InIter(ia), InIter(ia+s), 5);
28     for (unsigned i = 0; i < s; ++i)
29         assert(ia[i] == ir[i]);
30 }
31 
32 int main(int, char**)
33 {
34     test<forward_iterator<int*> >();
35     test<bidirectional_iterator<int*> >();
36     test<random_access_iterator<int*> >();
37     test<int*>();
38 
39   return 0;
40 }
41