tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
count.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_ALGORITHM_COUNT_HPP
4#define TETL_ALGORITHM_COUNT_HPP
5
7
8namespace etl {
9
20template <typename InputIt, typename T>
21[[nodiscard]] constexpr auto count(InputIt first, InputIt last, T const& value) ->
23{
24 auto result = typename etl::iterator_traits<InputIt>::difference_type{0};
25 for (; first != last; ++first) {
26 if (*first == value) {
27 ++result;
28 }
29 }
30 return result;
31}
32
33} // namespace etl
34
35#endif // TETL_ALGORITHM_COUNT_HPP
constexpr auto count(InputIt first, InputIt last, T const &value) -> typename iterator_traits< InputIt >::difference_type
Returns the number of elements in the range [first, last) satisfying specific criteria....
Definition count.hpp:21
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