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_iterators.h" 18 19 template <class InIter> 20 void 21 test() 22 { 23 int ia[] = {1, 2, 3, 4, 5}; 24 int ir[] = {5, 6, 7, 8, 9}; 25 const unsigned s = sizeof(ia) / sizeof(ia[0]); 26 std::iota(InIter(ia), InIter(ia+s), 5); 27 for (unsigned i = 0; i < s; ++i) 28 assert(ia[i] == ir[i]); 29 } 30 31 int main(int, char**) 32 { 33 test<forward_iterator<int*> >(); 34 test<bidirectional_iterator<int*> >(); 35 test<random_access_iterator<int*> >(); 36 test<int*>(); 37 38 return 0; 39 } 40