4#ifndef TETL_ALGORITHM_SEARCH_N_HPP
5#define TETL_ALGORITHM_SEARCH_N_HPP
7#include <etl/_functional/equal_to.hpp>
16template <
typename ForwardIt,
typename Size,
typename ValueT,
typename Predicate>
17[[nodiscard]]
constexpr auto search_n(ForwardIt first, ForwardIt last, Size count, ValueT
const& value, Predicate pred)
20 if (count <= Size{}) {
24 auto localCounter = Size{};
25 ForwardIt found =
nullptr;
27 for (; first != last; ++first) {
28 if (pred(*first, value)) {
30 if (found ==
nullptr) {
37 if (localCounter == count) {
45template <
typename ForwardIt,
typename Size,
typename ValueT>
46[[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:17
constexpr auto search_n(ForwardIt first, ForwardIt last, Size count, ValueT const &value) -> ForwardIt
Searches the range [first, last) for the first sequence of count identical elements,...
Definition search_n.hpp:46
Definition adjacent_find.hpp:9
Function object for performing comparisons. Unless specialised, invokes operator== on type T....
Definition equal_to.hpp:15