• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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<InputIterator InIter, OutputIterator<auto, InIter::reference> OutIter, class T>
13 //   requires HasEqualTo<InIter::value_type, T>
14 //   OutIter
15 //   remove_copy(InIter first, InIter last, OutIter result, const T& value);
16 
17 #include <algorithm>
18 #include <cassert>
19 
20 #include "test_iterators.h"
21 
22 template <class InIter, class OutIter>
23 void
test()24 test()
25 {
26     int ia[] = {0, 1, 2, 3, 4, 2, 3, 4, 2};
27     const unsigned sa = sizeof(ia)/sizeof(ia[0]);
28     int ib[sa];
29     OutIter r = std::remove_copy(InIter(ia), InIter(ia+sa), OutIter(ib), 2);
30     assert(base(r) == ib + sa-3);
31     assert(ib[0] == 0);
32     assert(ib[1] == 1);
33     assert(ib[2] == 3);
34     assert(ib[3] == 4);
35     assert(ib[4] == 3);
36     assert(ib[5] == 4);
37 }
38 
main()39 int main()
40 {
41     test<input_iterator<const int*>, output_iterator<int*> >();
42     test<input_iterator<const int*>, forward_iterator<int*> >();
43     test<input_iterator<const int*>, bidirectional_iterator<int*> >();
44     test<input_iterator<const int*>, random_access_iterator<int*> >();
45     test<input_iterator<const int*>, int*>();
46 
47     test<forward_iterator<const int*>, output_iterator<int*> >();
48     test<forward_iterator<const int*>, forward_iterator<int*> >();
49     test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
50     test<forward_iterator<const int*>, random_access_iterator<int*> >();
51     test<forward_iterator<const int*>, int*>();
52 
53     test<bidirectional_iterator<const int*>, output_iterator<int*> >();
54     test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
55     test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
56     test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
57     test<bidirectional_iterator<const int*>, int*>();
58 
59     test<random_access_iterator<const int*>, output_iterator<int*> >();
60     test<random_access_iterator<const int*>, forward_iterator<int*> >();
61     test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
62     test<random_access_iterator<const int*>, random_access_iterator<int*> >();
63     test<random_access_iterator<const int*>, int*>();
64 
65     test<const int*, output_iterator<int*> >();
66     test<const int*, forward_iterator<int*> >();
67     test<const int*, bidirectional_iterator<int*> >();
68     test<const int*, random_access_iterator<int*> >();
69     test<const int*, int*>();
70 }
71