blob: 3128674253db37e572f9c19c1aa0a07e4fb63598 [file] [log] [blame]
Howard Hinnant40c7ef92010-05-26 18:53:44 +00001//===----------------------------------------------------------------------===//
2//
Chandler Carruth57b08b02019-01-19 10:56:40 +00003// 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 Hinnant40c7ef92010-05-26 18:53:44 +00006//
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 Clow32227082013-01-05 03:21:01 +000017#include "test_iterators.h"
Howard Hinnant40c7ef92010-05-26 18:53:44 +000018
19template <class InIter>
20void
21test()
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
31int main()
32{
33 test<forward_iterator<int*> >();
34 test<bidirectional_iterator<int*> >();
35 test<random_access_iterator<int*> >();
36 test<int*>();
37}