blob: 86772e44e80503571811518f14b5be0d7a63ed42 [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
3// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
4//
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
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 "../../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}