blob: 51b05438b68c0f3faf1ccdef2c7b12d024b3db10 [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, class T>
13// requires OutputIterator<Iter, Iter::reference>
14// && OutputIterator<Iter, const T&>
15// && HasEqualTo<Iter::value_type, T>
16// void
17// replace(Iter first, Iter last, const T& old_value, const T& new_value);
18
19#include <algorithm>
20#include <cassert>
21
22#include "../../iterators.h"
23
24template <class Iter>
25void
26test()
27{
28 int ia[] = {0, 1, 2, 3, 4};
29 const unsigned sa = sizeof(ia)/sizeof(ia[0]);
30 std::replace(Iter(ia), Iter(ia+sa), 2, 5);
31 assert(ia[0] == 0);
32 assert(ia[1] == 1);
33 assert(ia[2] == 5);
34 assert(ia[3] == 3);
35 assert(ia[4] == 4);
36}
37
38int main()
39{
40 test<forward_iterator<int*> >();
41 test<bidirectional_iterator<int*> >();
42 test<random_access_iterator<int*> >();
43 test<int*>();
44}