Howard Hinnant | 40c7ef9 | 2010-05-26 18:53:44 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Chandler Carruth | 57b08b0 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 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 |
Howard Hinnant | 40c7ef9 | 2010-05-26 18:53:44 +0000 | [diff] [blame] | 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 | |
Marshall Clow | 7fc6a55 | 2019-05-31 18:35:30 +0000 | [diff] [blame] | 17 | #include "test_macros.h" |
Marshall Clow | 3222708 | 2013-01-05 03:21:01 +0000 | [diff] [blame] | 18 | #include "test_iterators.h" |
Howard Hinnant | 40c7ef9 | 2010-05-26 18:53:44 +0000 | [diff] [blame] | 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 | |
JF Bastien | 2df59c5 | 2019-02-04 20:31:13 +0000 | [diff] [blame] | 32 | int main(int, char**) |
Howard Hinnant | 40c7ef9 | 2010-05-26 18:53:44 +0000 | [diff] [blame] | 33 | { |
| 34 | test<forward_iterator<int*> >(); |
| 35 | test<bidirectional_iterator<int*> >(); |
| 36 | test<random_access_iterator<int*> >(); |
| 37 | test<int*>(); |
JF Bastien | 2df59c5 | 2019-02-04 20:31:13 +0000 | [diff] [blame] | 38 | |
| 39 | return 0; |
Howard Hinnant | 40c7ef9 | 2010-05-26 18:53:44 +0000 | [diff] [blame] | 40 | } |