Iros
 
Loading...
Searching...
No Matches
partition_copy.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace di::container {
9namespace detail {
11 template<concepts::InputIterator It, concepts::SentinelFor<It> Sent, concepts::WeaklyIncrementable OutTrue,
12 concepts::WeaklyIncrementable OutFalse, typename Proj = function::Identity,
13 concepts::IndirectUnaryPredicate<meta::Projected<It, Proj>> Pred>
15 constexpr auto operator()(It first, Sent last, OutTrue out_true, OutFalse out_false, Pred pred,
17 for (; first != last; ++first) {
18 if (function::invoke(pred, function::invoke(proj, *first))) {
19 *out_true = *first;
20 ++out_true;
21 } else {
22 *out_false = *first;
23 ++out_false;
24 }
25 }
26 return { util::move(first), util::move(out_true), util::move(out_false) };
27 }
28
29 template<concepts::InputContainer Con, concepts::WeaklyIncrementable OutTrue,
30 concepts::WeaklyIncrementable OutFalse, typename Proj = function::Identity,
31 concepts::IndirectUnaryPredicate<meta::Projected<meta::ContainerIterator<Con>, Proj>> Pred>
32 requires(concepts::IndirectlyCopyable<meta::ContainerIterator<Con>, OutTrue> &&
33 concepts::IndirectlyCopyable<meta::ContainerIterator<Con>, OutFalse>)
34 constexpr auto operator()(Con&& container, OutTrue out_true, OutFalse out_false, Pred pred,
35 Proj proj = {}) const
36 -> InOutOutResult<meta::BorrowedIterator<Con>, OutTrue, OutFalse> {
37 return (*this)(container::begin(container), container::end(container), util::move(out_true),
38 util::move(out_false), util::ref(pred), util::ref(proj));
39 }
40 };
41}
42
44}
45
46namespace di {
48}
Definition indirectly_copyable.h:9
Definition sequence.h:13
Definition sequence.h:12
constexpr auto partition_copy
Definition partition_copy.h:43
constexpr auto end
Definition end.h:47
constexpr auto begin
Definition begin.h:44
constexpr auto invoke
Definition invoke.h:100
Conditional< concepts::BorrowedContainer< Con >, ContainerIterator< Con >, container::Dangling > BorrowedIterator
Definition borrowed_iterator.h:11
constexpr auto ref
Definition reference_wrapper.h:98
Definition zstring_parser.h:9
constexpr auto proj
Definition proj.h:59
Definition in_out_out_result.h:8
Definition partition_copy.h:10