tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
default_searcher.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_FUNCTIONAL_DEFAULT_SEARCHER_HPP
4#define TETL_FUNCTIONAL_DEFAULT_SEARCHER_HPP
5
11#include <etl/_utility/pair.hpp>
12
13namespace etl {
14
18template <typename ForwardIter, typename Predicate = equal_to<>>
20 constexpr default_searcher(ForwardIter f, ForwardIter l, Predicate p = Predicate())
21 : _first(f)
22 , _last(l)
23 , _predicate(p)
24 {
25 }
26
27 template <typename ForwardIter2>
28 constexpr auto operator()(ForwardIter2 f, ForwardIter2 l) const -> etl::pair<ForwardIter2, ForwardIter2>
29 {
30 if (auto i = etl::search(f, l, _first, _last, _predicate); i != l) {
31 auto j = etl::next(i, etl::distance(_first, _last));
33 }
34
36 }
37
38private:
39 ForwardIter _first;
40 ForwardIter _last;
41 Predicate _predicate;
42};
43
44} // namespace etl
45
46#endif // TETL_FUNCTIONAL_DEFAULT_SEARCHER_HPP
constexpr auto search(FwdIt1 first, FwdIt1 last, FwdIt2 sFirst, FwdIt2 sLast, Predicate pred) -> FwdIt1
Searches for the first occurrence of the sequence of elements [sFirst, sLast) in the range [first,...
Definition search.hpp:24
constexpr auto next(InputIt it, typename iterator_traits< InputIt >::difference_type n=1) -> InputIt
Return the nth successor of iterator it.
Definition next.hpp:14
constexpr auto distance(It first, It last) -> typename iterator_traits< It >::difference_type
Returns the number of hops from first to last.
Definition distance.hpp:16
Definition adjacent_find.hpp:8
constexpr auto operator()(ForwardIter2 f, ForwardIter2 l) const -> etl::pair< ForwardIter2, ForwardIter2 >
Definition default_searcher.hpp:28
constexpr default_searcher(ForwardIter f, ForwardIter l, Predicate p=Predicate())
Definition default_searcher.hpp:20
etl::pair is a class template that provides a way to store two heterogeneous objects as a single unit...
Definition pair.hpp:36