Iros
 
Loading...
Searching...
No Matches
adjacent_find.h
Go to the documentation of this file.
1#pragma once
2
6#include "di/function/equal.h"
8
9namespace di::container {
10namespace detail {
12 template<concepts::ForwardIterator Iter, concepts::SentinelFor<Iter> Sent, typename Proj = function::Identity,
13 concepts::IndirectBinaryPredicate<meta::Projected<Iter, Proj>> Pred = function::Equal>
14 constexpr auto operator()(Iter fast, Sent last, Pred pred = {}, Proj proj = {}) const -> Iter {
15 if (fast == last) {
16 return fast;
17 }
18 auto slow = fast++;
19 for (; fast != last; ++fast, ++slow) {
20 if (function::invoke(pred, function::invoke(proj, *slow), function::invoke(proj, *fast))) {
21 return slow;
22 }
23 }
24 return fast;
25 }
26
27 template<concepts::ForwardContainer Con, typename Proj = function::Identity,
28 concepts::IndirectBinaryPredicate<meta::Projected<meta::ContainerIterator<Con>, Proj>> Pred =
29 function::Equal>
30 constexpr auto operator()(Con&& container, Pred pred = {}, Proj proj = {}) const
33 }
34 };
35}
36
38}
39
40namespace di {
42}
Definition sequence.h:13
Definition sequence.h:12
constexpr auto adjacent_find
Definition adjacent_find.h:37
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 adjacent_find.h:11
constexpr auto operator()(Con &&container, Pred pred={}, Proj proj={}) const -> meta::BorrowedIterator< Con >
Definition adjacent_find.h:30
constexpr auto operator()(Iter fast, Sent last, Pred pred={}, Proj proj={}) const -> Iter
Definition adjacent_find.h:14