di 0.1.0
Loading...
Searching...
No Matches
find_if.h
Go to the documentation of this file.
1#pragma once
2
8
9namespace di::container {
10namespace detail {
11 struct FindIfFunction {
12 template<concepts::InputIterator Iter, concepts::SentinelFor<Iter> Sent, typename Proj = function::Identity,
13 concepts::IndirectUnaryPredicate<meta::Projected<Iter, Proj>> Pred>
14 constexpr auto operator()(Iter first, Sent last, Pred pred, Proj projection = {}) const -> Iter {
15 for (; first != last; ++first) {
16 if (function::invoke(pred, function::invoke(projection, *first))) {
17 break;
18 }
19 }
20 return first;
21 }
22
23 template<concepts::InputContainer Con, typename Proj = function::Identity,
24 concepts::IndirectUnaryPredicate<meta::Projected<meta::ContainerIterator<Con>, Proj>> Pred>
25 constexpr auto operator()(Con&& container, Pred pred, Proj proj = {}) const -> meta::BorrowedIterator<Con> {
26 return (*this)(container::begin(container), container::end(container), util::ref(pred), util::ref(proj));
27 }
28 };
29}
30
31constexpr inline auto find_if = detail::FindIfFunction {};
32}
33
34namespace di {
36}
constexpr auto last(concepts::detail::ConstantVector auto &vector, size_t count)
Definition vector_last.h:13
constexpr auto first(concepts::detail::ConstantVector auto &vector, size_t count)
Definition vector_first.h:13
Definition sequence.h:12
constexpr auto find_if
Definition find_if.h:31
constexpr auto end
Definition end.h:55
constexpr auto begin
Definition begin.h:52
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 any_storable.h:9
constexpr auto proj
Definition proj.h:59