1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 // template<InputIterator InIter, OutputIterator<auto, InIter::reference> OutIter, class T>
12 // requires HasEqualTo<InIter::value_type, T>
13 // constexpr OutIter // constexpr after C++17
14 // remove_copy(InIter first, InIter last, OutIter result, const T& value);
19 #include "test_macros.h"
20 #include "test_iterators.h"
23 TEST_CONSTEXPR
bool test_constexpr() {
24 int ia
[] = {1, 3, 5, 2, 5, 6};
25 int ib
[std::size(ia
)] = {0};
27 auto it
= std::remove_copy(std::begin(ia
), std::end(ia
), std::begin(ib
), 5);
29 return std::distance(std::begin(ib
), it
) == static_cast<int>(std::size(ia
) - 2) // we removed two elements
30 && std::none_of(std::begin(ib
), it
, [](int a
) {return a
== 5;})
31 && std::all_of (it
, std::end(ib
), [](int a
) {return a
== 0;})
36 template <class InIter
, class OutIter
>
40 int ia
[] = {0, 1, 2, 3, 4, 2, 3, 4, 2};
41 const unsigned sa
= sizeof(ia
)/sizeof(ia
[0]);
43 OutIter r
= std::remove_copy(InIter(ia
), InIter(ia
+sa
), OutIter(ib
), 2);
44 assert(base(r
) == ib
+ sa
-3);
55 test
<input_iterator
<const int*>, output_iterator
<int*> >();
56 test
<input_iterator
<const int*>, forward_iterator
<int*> >();
57 test
<input_iterator
<const int*>, bidirectional_iterator
<int*> >();
58 test
<input_iterator
<const int*>, random_access_iterator
<int*> >();
59 test
<input_iterator
<const int*>, int*>();
61 test
<forward_iterator
<const int*>, output_iterator
<int*> >();
62 test
<forward_iterator
<const int*>, forward_iterator
<int*> >();
63 test
<forward_iterator
<const int*>, bidirectional_iterator
<int*> >();
64 test
<forward_iterator
<const int*>, random_access_iterator
<int*> >();
65 test
<forward_iterator
<const int*>, int*>();
67 test
<bidirectional_iterator
<const int*>, output_iterator
<int*> >();
68 test
<bidirectional_iterator
<const int*>, forward_iterator
<int*> >();
69 test
<bidirectional_iterator
<const int*>, bidirectional_iterator
<int*> >();
70 test
<bidirectional_iterator
<const int*>, random_access_iterator
<int*> >();
71 test
<bidirectional_iterator
<const int*>, int*>();
73 test
<random_access_iterator
<const int*>, output_iterator
<int*> >();
74 test
<random_access_iterator
<const int*>, forward_iterator
<int*> >();
75 test
<random_access_iterator
<const int*>, bidirectional_iterator
<int*> >();
76 test
<random_access_iterator
<const int*>, random_access_iterator
<int*> >();
77 test
<random_access_iterator
<const int*>, int*>();
79 test
<const int*, output_iterator
<int*> >();
80 test
<const int*, forward_iterator
<int*> >();
81 test
<const int*, bidirectional_iterator
<int*> >();
82 test
<const int*, random_access_iterator
<int*> >();
83 test
<const int*, int*>();
86 static_assert(test_constexpr());