13#ifndef RANGES_V3_ALGORITHM_FIND_END_HPP
14#define RANGES_V3_ALGORITHM_FIND_END_HPP
31#include <range/v3/utility/static_const.hpp>
34#include <range/v3/detail/prologue.hpp>
41 template(
typename I,
typename S)(
42 requires input_iterator<I> AND sentinel_for<S, I>)
43 constexpr I next_to_if(I i, S s, std::true_type)
45 return ranges::next(i, s);
48 template(
typename I,
typename S)(
49 requires input_iterator<I> AND sentinel_for<S, I>)
50 constexpr S next_to_if(I, S s, std::false_type)
55 template(
bool B,
typename I,
typename S)(
56 requires input_iterator<I> AND sentinel_for<S, I>)
57 constexpr meta::if_c<B, I, S> next_to_if(I i, S s)
59 return detail::next_to_if(std::move(i), std::move(s),
meta::bool_<B>{});
62 template<
typename I1,
typename S1,
typename I2,
typename S2,
typename R,
64 constexpr subrange<I1> find_end_impl(I1 begin1, S1 end1, I2 begin2, S2 end2, R pred, P proj,
65 std::forward_iterator_tag, std::forward_iterator_tag)
68 I1 res_begin, res_end;
71 auto e1 = ranges::next(begin1, end1);
79 return {(found ? res_begin : begin1), (found ? res_end : begin1)};
96 return {(found ? res_begin : tmp1), (found ? res_end : tmp1)};
106 template<
typename I1,
typename I2,
typename R,
typename P>
107 constexpr subrange<I1> find_end_impl(I1 begin1, I1 end1, I2 begin2, I2 end2, R pred, P proj,
108 std::bidirectional_iterator_tag,
109 std::bidirectional_iterator_tag)
135 else if(m1 == begin1)
143 template<
typename I1,
typename I2,
typename R,
typename P>
144 constexpr subrange<I1> find_end_impl(I1 begin1, I1 end1, I2 begin2, I2 end2, R pred, P proj,
145 std::random_access_iterator_tag,
146 std::random_access_iterator_tag)
150 auto len2 = end2 - begin2;
153 auto len1 = end1 - begin1;
181 RANGES_FUNC_BEGIN(find_end)
184 template(typename I1,
193 constexpr
subrange<I1> RANGES_FUNC(find_end)(
194 I1 begin1, S1 end1, I2 begin2, S2 end2, R pred = R{}, P proj = P{})
196 constexpr bool Bidi =
197 bidirectional_iterator<I1> && bidirectional_iterator<I2>;
198 return detail::find_end_impl(begin1,
199 detail::next_to_if<Bidi>(begin1, end1),
201 detail::next_to_if<Bidi>(begin2, end2),
204 iterator_tag_of<I1>(),
205 iterator_tag_of<I2>());
209 template(
typename Rng1,
215 constexpr borrowed_subrange_t<Rng1> RANGES_FUNC(find_end)(
216 Rng1 && rng1, Rng2 && rng2, R pred = R{}, P proj = P{})
218 return (*
this)(begin(rng1),
226 RANGES_FUNC_END(find_end)
230 using ranges::find_end;
235#include <range/v3/detail/epilogue.hpp>
The forward_iterator concept.
The forward_range concept.
The indirect_relation concept.
The sentinel_for concept.
decltype(begin(declval(Rng &))) iterator_t
Definition access.hpp:698
std::integral_constant< bool, B > bool_
An integral constant wrapper for bool.
Definition meta.hpp:168
typename Fn::template invoke< Args... > invoke
Evaluate the invocable Fn with the arguments Args.
Definition meta.hpp:541
Definition comparisons.hpp:28
Definition identity.hpp:25
Definition subrange.hpp:196