Iros
 
Loading...
Searching...
No Matches
count_if.h
Go to the documentation of this file.
1#pragma once
2
8
9namespace di::container {
10namespace detail {
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
16 auto result = meta::IteratorSSizeType<Iter> { 0 };
17 for (; first != last; ++first) {
18 if (function::invoke(pred, function::invoke(projection, *first))) {
19 result++;
20 }
21 }
22 return result;
23 }
24
25 template<concepts::InputContainer Con, typename Proj = function::Identity,
26 concepts::IndirectUnaryPredicate<meta::Projected<meta::ContainerIterator<Con>, Proj>> Pred>
27 constexpr auto operator()(Con&& container, Pred pred, Proj proj = {}) const -> meta::ContainerSSizeType<Con> {
29 }
30 };
31}
32
33constexpr inline auto count_if = detail::CountIfFunction {};
34}
35
36namespace di {
38}
Definition sequence.h:13
Definition sequence.h:12
constexpr auto end
Definition end.h:47
constexpr auto count_if
Definition count_if.h:33
constexpr auto begin
Definition begin.h:44
constexpr auto invoke
Definition invoke.h:100
IteratorSSizeType< ContainerIterator< T > > ContainerSSizeType
Definition container_ssize_type.h:8
decltype(container::iterator_ssize_type(types::in_place_type< meta::RemoveCVRef< T > >)) IteratorSSizeType
Definition iterator_ssize_type.h:8
constexpr auto ref
Definition reference_wrapper.h:98
Definition zstring_parser.h:9
constexpr auto proj
Definition proj.h:59
constexpr auto operator()(Con &&container, Pred pred, Proj proj={}) const -> meta::ContainerSSizeType< Con >
Definition count_if.h:27
constexpr auto operator()(Iter first, Sent last, Pred pred, Proj projection={}) const -> meta::IteratorSSizeType< Iter >
Definition count_if.h:14