1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // template <class InputIterator, class OutputIterator1,
13 // class OutputIterator2, class Predicate>
14 // constexpr pair<OutputIterator1, OutputIterator2> // constexpr after C++17
15 // partition_copy(InputIterator first, InputIterator last,
16 // OutputIterator1 out_true, OutputIterator2 out_false,
22 #include "test_macros.h"
23 #include "test_iterators.h"
27 TEST_CONSTEXPR bool operator()(const int& i) const {return i & 1;}
31 TEST_CONSTEXPR bool test_constexpr() {
32 int ia[] = {1, 3, 5, 2, 4, 6};
36 auto p = std::partition_copy(std::begin(ia), std::end(ia),
37 std::begin(r1), std::begin(r2), is_odd());
39 return std::all_of(std::begin(r1), p.first, is_odd())
40 && std::all_of(p.first, std::end(r1), [](int a){return a == 0;})
41 && std::none_of(std::begin(r2), p.second, is_odd())
42 && std::all_of(p.second, std::end(r2), [](int a){return a == 0;})
50 const int ia[] = {1, 2, 3, 4, 6, 8, 5, 7};
53 typedef std::pair<output_iterator<int*>, int*> P;
54 P p = std::partition_copy(input_iterator<const int*>(std::begin(ia)),
55 input_iterator<const int*>(std::end(ia)),
56 output_iterator<int*>(r1), r2, is_odd());
57 assert(p.first.base() == r1 + 4);
62 assert(p.second == r2 + 4);
70 static_assert(test_constexpr());