Howard Hinnant | 40c7ef9 | 2010-05-26 18:53:44 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Howard Hinnant | 412dbeb | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | 40c7ef9 | 2010-05-26 18:53:44 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <numeric> |
| 11 | |
| 12 | // template <class ForwardIterator, class T> |
| 13 | // void iota(ForwardIterator first, ForwardIterator last, T value); |
| 14 | |
| 15 | #include <numeric> |
| 16 | #include <cassert> |
| 17 | |
| 18 | #include "../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() |
| 33 | { |
| 34 | test<forward_iterator<int*> >(); |
| 35 | test<bidirectional_iterator<int*> >(); |
| 36 | test<random_access_iterator<int*> >(); |
| 37 | test<int*>(); |
| 38 | } |