1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <algorithm>
11
12// template<ForwardIterator Iter, Callable Generator>
13//   requires OutputIterator<Iter, Generator::result_type>
14//         && CopyConstructible<Generator>
15//   void
16//   generate(Iter first, Iter last, Generator gen);
17
18#include <algorithm>
19#include <cassert>
20
21#include "test_iterators.h"
22
23struct gen_test
24{
25    int operator()() const {return 1;}
26};
27
28template <class Iter>
29void
30test()
31{
32    const unsigned n = 4;
33    int ia[n] = {0};
34    std::generate(Iter(ia), Iter(ia+n), gen_test());
35    assert(ia[0] == 1);
36    assert(ia[1] == 1);
37    assert(ia[2] == 1);
38    assert(ia[3] == 1);
39}
40
41int main()
42{
43    test<forward_iterator<int*> >();
44    test<bidirectional_iterator<int*> >();
45    test<random_access_iterator<int*> >();
46    test<int*>();
47}
48