tetl
0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
count_if.hpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: BSL-1.0
2
3
#ifndef TETL_ALGORITHM_COUNT_IF_HPP
4
#define TETL_ALGORITHM_COUNT_IF_HPP
5
6
#include <
etl/_iterator/iterator_traits.hpp
>
7
8
namespace
etl
{
9
21
template
<
typename
InputIt,
typename
Predicate>
22
[[nodiscard]]
constexpr
auto
count_if
(InputIt first, InputIt last, Predicate p) ->
23
typename
iterator_traits<InputIt>::difference_type
24
{
25
auto
result =
typename
etl::iterator_traits<InputIt>::difference_type
{0};
26
for
(; first != last; ++first) {
27
if
(p(*first)) {
28
++result;
29
}
30
}
31
return
result;
32
}
33
34
}
// namespace etl
35
36
#endif
// TETL_ALGORITHM_COUNT_IF_HPP
etl::count_if
constexpr auto count_if(InputIt first, InputIt last, Predicate p) -> typename iterator_traits< InputIt >::difference_type
Returns the number of elements in the range [first, last) satisfying specific criteria....
Definition
count_if.hpp:22
iterator_traits.hpp
etl
Definition
adjacent_find.hpp:8
etl::iterator_traits
iterator_traits is the type trait class that provides uniform interface to the properties of LegacyIt...
Definition
iterator_traits.hpp:47
include
etl
_algorithm
count_if.hpp
Generated on Sat Mar 8 2025 16:19:59 for tetl by
1.14.0