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 <class InputIterator, class OutputIterator1,
12 // class OutputIterator2, class Predicate>
13 // constexpr pair<OutputIterator1, OutputIterator2> // constexpr after C++17
14 // partition_copy(InputIterator first, InputIterator last,
15 // OutputIterator1 out_true, OutputIterator2 out_false,
21 #include "test_macros.h"
22 #include "test_iterators.h"
26 TEST_CONSTEXPR
bool operator()(const int& i
) const {return i
& 1;}
30 TEST_CONSTEXPR
bool test_constexpr() {
31 int ia
[] = {1, 3, 5, 2, 4, 6};
35 auto p
= std::partition_copy(std::begin(ia
), std::end(ia
),
36 std::begin(r1
), std::begin(r2
), is_odd());
38 return std::all_of(std::begin(r1
), p
.first
, is_odd())
39 && std::all_of(p
.first
, std::end(r1
), [](int a
){return a
== 0;})
40 && std::none_of(std::begin(r2
), p
.second
, is_odd())
41 && std::all_of(p
.second
, std::end(r2
), [](int a
){return a
== 0;})
49 const int ia
[] = {1, 2, 3, 4, 6, 8, 5, 7};
52 typedef std::pair
<cpp17_output_iterator
<int*>, int*> P
;
53 P p
= std::partition_copy(cpp17_input_iterator
<const int*>(std::begin(ia
)),
54 cpp17_input_iterator
<const int*>(std::end(ia
)),
55 cpp17_output_iterator
<int*>(r1
), r2
, is_odd());
56 assert(base(p
.first
) == r1
+ 4);
61 assert(p
.second
== r2
+ 4);
69 static_assert(test_constexpr());