Iros
 
Loading...
Searching...
No Matches
set_intersection.h
Go to the documentation of this file.
1#pragma once
2
8
9namespace di::container {
10namespace detail {
12 template<concepts::InputIterator It1, concepts::SentinelFor<It1> Sent1, concepts::InputIterator It2,
13 concepts::SentinelFor<It2> Sent2, concepts::WeaklyIncrementable Out, typename Comp = function::Compare,
14 typename Proj1 = function::Identity, typename Proj2 = function::Identity>
16 constexpr auto operator()(It1 first1, Sent1 last1, It2 first2, Sent2 last2, Out out, Comp comp = {},
17 Proj1 proj1 = {}, Proj2 proj2 = {}) const -> InInOutResult<It1, It2, Out> {
18 // While both ranges are non-empty, compare them to see if the element occurs in both ranges.
19 while (first1 != last1 && first2 != last2) {
20 auto result =
21 function::invoke(comp, function::invoke(proj1, *first1), function::invoke(proj2, *first2));
22 if (result == 0) {
23 *out = *first1++;
24 ++first2;
25 ++out;
26 } else if (result < 0) {
27 ++first1;
28 } else {
29 ++first2;
30 }
31 }
32
33 // Skip to the end of the range 1 and range 2.
34 return { container::next(first1, last1), container::next(first2, last2), util::move(out) };
35 }
36
37 template<concepts::InputContainer Con1, concepts::InputContainer Con2, concepts::WeaklyIncrementable Out,
38 typename Comp = function::Compare, typename Proj1 = function::Identity,
39 typename Proj2 = function::Identity>
40 requires(
41 concepts::Mergeable<meta::ContainerIterator<Con1>, meta::ContainerIterator<Con2>, Out, Comp, Proj1, Proj2>)
42 constexpr auto operator()(Con1&& container1, Con2&& container2, Out out, Comp comp = {}, Proj1 proj1 = {},
43 Proj2 proj2 = {}) const
45 return (*this)(container::begin(container1), container::end(container1), container::begin(container2),
46 container::end(container2), util::move(out), util::ref(comp), util::ref(proj1),
47 util::ref(proj2));
48 }
49 };
50}
51
53}
54
55namespace di {
57}
Definition mergeable.h:14
Definition sequence.h:13
Definition sequence.h:12
constexpr auto next
Definition next.h:35
constexpr auto end
Definition end.h:47
constexpr auto set_intersection
Definition set_intersection.h:52
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
decltype(container::begin(util::declval< T & >())) ContainerIterator
Definition container_iterator.h:8
constexpr auto ref
Definition reference_wrapper.h:98
Definition zstring_parser.h:9
Definition set_intersection.h:11