# 11 Algorithms library [algorithms]

## 11.3 Non-modifying sequence operations [alg.nonmodifying]

### 11.3.6 Find end [alg.find.end]

``` template <ForwardIterator I1, Sentinel<I1> S1, ForwardIterator I2, Sentinel<I2> S2, class Proj = identity, IndirectRelation<I2, projected<I1, Proj>> Pred = equal_to<>> I1 find_end(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = Pred{}, Proj proj = Proj{}); template <ForwardRange Rng1, ForwardRange Rng2, class Proj = identity, IndirectRelation<iterator_t<Rng2>, projected<iterator_t<Rng>, Proj>> Pred = equal_to<>> safe_iterator_t<Rng1> find_end(Rng1&& rng1, Rng2&& rng2, Pred pred = Pred{}, Proj proj = Proj{}); ```

Effects: Finds a subsequence of equal values in a sequence.

Returns: The last iterator i in the range [first1,last1 - (last2 - first2)) such that for every non-negative integer n < (last2 - first2), the following condition holds: invoke(pred, invoke(proj, *(i + n)), *(first2 + n)) != false. Returns last1 if [first2,last2) is empty or if no such iterator is found.

Complexity: At most (last2 - first2) * (last1 - first1 - (last2 - first2) + 1) applications of the corresponding predicate and projection.