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
7
8namespace etl {
9
21template <typename InputIt, typename Predicate>
22[[nodiscard]] constexpr auto count_if(InputIt first, InputIt last, Predicate p) ->
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
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
Definition adjacent_find.hpp:8
iterator_traits is the type trait class that provides uniform interface to the properties of LegacyIt...
Definition iterator_traits.hpp:47