diff options
Diffstat (limited to 'test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp')
-rw-r--r-- | test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp index bf5f79cf83592..4ace1494d858c 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp +++ b/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp @@ -11,14 +11,29 @@ // template<InputIterator InIter, OutputIterator<auto, InIter::reference> OutIter, class T> // requires HasEqualTo<InIter::value_type, T> -// OutIter +// constexpr OutIter // constexpr after C++17 // remove_copy(InIter first, InIter last, OutIter result, const T& value); #include <algorithm> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" +#if TEST_STD_VER > 17 +TEST_CONSTEXPR bool test_constexpr() { + int ia[] = {1, 3, 5, 2, 5, 6}; + int ib[std::size(ia)] = {0}; + + auto it = std::remove_copy(std::begin(ia), std::end(ia), std::begin(ib), 5); + + return std::distance(std::begin(ib), it) == (std::size(ia) - 2) // we removed two elements + && std::none_of(std::begin(ib), it, [](int a) {return a == 5;}) + && std::all_of (it, std::end(ib), [](int a) {return a == 0;}) + ; + } +#endif + template <class InIter, class OutIter> void test() @@ -67,4 +82,8 @@ int main() test<const int*, bidirectional_iterator<int*> >(); test<const int*, random_access_iterator<int*> >(); test<const int*, int*>(); + +#if TEST_STD_VER > 17 + static_assert(test_constexpr()); +#endif } |