blob: 3b009d7b72a20f88ec74db3776fc9214afab27b6 [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnant5b08a8a2010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnant3e519522010-05-11 19:42:16 +00004//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <algorithm>
11
Howard Hinnant664ae812010-08-22 00:08:10 +000012// template<ForwardIterator Iter, Callable Generator>
13// requires OutputIterator<Iter, Generator::result_type>
14// && CopyConstructible<Generator>
Howard Hinnant3e519522010-05-11 19:42:16 +000015// void
16// generate(Iter first, Iter last, Generator gen);
17
18#include <algorithm>
19#include <cassert>
20
21#include "../../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}