blob: 2cf99f8d44e3b25a092e2116ccf5b4e80a6c6c8e [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 Clow7fc6a552019-05-31 18:35:30 +000017#include "test_macros.h"
Marshall Clow32227082013-01-05 03:21:01 +000018#include "test_iterators.h"
Howard Hinnant40c7ef92010-05-26 18:53:44 +000019
20template <class InIter>
21void
22test()
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 Bastien2df59c52019-02-04 20:31:13 +000032int main(int, char**)
Howard Hinnant40c7ef92010-05-26 18:53:44 +000033{
34 test<forward_iterator<int*> >();
35 test<bidirectional_iterator<int*> >();
36 test<random_access_iterator<int*> >();
37 test<int*>();
JF Bastien2df59c52019-02-04 20:31:13 +000038
39 return 0;
Howard Hinnant40c7ef92010-05-26 18:53:44 +000040}