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
6
#include <
etl/_iterator/iterator_traits.hpp
>
7
8
namespace
etl
{
9
20
template
<
typename
InputIt,
typename
T>
21
[[nodiscard]]
constexpr
auto
count
(InputIt first, InputIt last, T
const
& value) ->
22
typename
iterator_traits<InputIt>::difference_type
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
etl::count
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
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.hpp
Generated on Sat Mar 8 2025 16:19:59 for tetl by
1.14.0