3#ifndef TETL_ALGORITHM_SEARCH_N_HPP
4#define TETL_ALGORITHM_SEARCH_N_HPP
15template <
typename ForwardIt,
typename Size,
typename ValueT,
typename Predicate>
16[[nodiscard]]
constexpr auto search_n(ForwardIt first, ForwardIt last, Size
count, ValueT
const& value, Predicate pred)
19 if (
count <= Size{}) {
23 auto localCounter = Size{};
24 ForwardIt found =
nullptr;
26 for (; first != last; ++first) {
27 if (pred(*first, value)) {
29 if (found ==
nullptr) {
36 if (localCounter ==
count) {
44template <
typename ForwardIt,
typename Size,
typename ValueT>
45[[nodiscard]]
constexpr auto search_n(ForwardIt first, ForwardIt last, Size
count, ValueT
const& value) -> ForwardIt
constexpr auto search_n(ForwardIt first, ForwardIt last, Size count, ValueT const &value, Predicate pred) -> ForwardIt
Searches the range [first, last) for the first sequence of count identical elements,...
Definition search_n.hpp:16
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
Function object for performing comparisons. Unless specialised, invokes operator== on type T....
Definition equal_to.hpp:14