|
780 | 780 | find_if_not(R&& r, Pred pred, Proj proj = {});
|
781 | 781 | }
|
782 | 782 |
|
| 783 | + // \ref{alg.find.last}, find last |
| 784 | + namespace ranges { |
| 785 | + template<@\libconcept{forward_iterator}@ I, @\libconcept{sentinel_for}@<I> S, class T, class Proj = identity> |
| 786 | + requires @\libconcept{indirect_binary_predicate}@<ranges::equal_to, projected<I, Proj>, const T*> |
| 787 | + constexpr subrange<I> find_last(I first, S last, const T& value, Proj proj = {}); |
| 788 | + template<@\libconcept{forward_range}@ R, class T, class Proj = identity> |
| 789 | + requires |
| 790 | + @\libconcept{indirect_binary_predicate}@<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*> |
| 791 | + constexpr borrowed_subrange_t<R> find_last(R&& r, const T& value, Proj proj = {}); |
| 792 | + template<@\libconcept{forward_iterator}@ I, @\libconcept{sentinel_for}@<I> S, class Proj = identity, |
| 793 | + @\libconcept{indirect_unary_predicate}@<projected<I, Proj>> Pred> |
| 794 | + constexpr subrange<I> find_last_if(I first, S last, Pred pred, Proj proj = {}); |
| 795 | + template<@\libconcept{forward_range}@ R, class Proj = identity, |
| 796 | + @\libconcept{indirect_unary_predicate}@<projected<iterator_t<R>, Proj>> Pred> |
| 797 | + constexpr borrowed_subrange_t<R> find_last_if(R&& r, Pred pred, Proj proj = {}); |
| 798 | + template<@\libconcept{forward_iterator}@ I, @\libconcept{sentinel_for}@<I> S, class Proj = identity, |
| 799 | + @\libconcept{indirect_unary_predicate}@<projected<I, Proj>> Pred> |
| 800 | + constexpr subrange<I> find_last_if_not(I first, S last, Pred pred, Proj proj = {}); |
| 801 | + template<@\libconcept{forward_range}@ R, class Proj = identity, |
| 802 | + @\libconcept{indirect_unary_predicate}@<projected<iterator_t<R>, Proj>> Pred> |
| 803 | + constexpr borrowed_subrange_t<R> find_last_if_not(R&& r, Pred pred, Proj proj = {}); |
| 804 | + } |
| 805 | + |
783 | 806 | // \ref{alg.find.end}, find end
|
784 | 807 | template<class ForwardIterator1, class ForwardIterator2>
|
785 | 808 | constexpr ForwardIterator1
|
|
3514 | 3537 | of the corresponding predicate and any projection.
|
3515 | 3538 | \end{itemdescr}
|
3516 | 3539 |
|
| 3540 | +\rSec2[alg.find.last]{Find last} |
| 3541 | + |
| 3542 | +\indexlibraryglobal{find_last}% |
| 3543 | +\begin{itemdecl} |
| 3544 | +template<@\libconcept{forward_iterator}@ I, @\libconcept{sentinel_for}@<I> S, class T, class Proj = identity> |
| 3545 | + requires @\libconcept{indirect_binary_predicate}@<ranges::equal_to, projected<I, Proj>, const T*> |
| 3546 | + constexpr subrange<I> ranges::find_last(I first, S last, const T& value, Proj proj = {}); |
| 3547 | +template<@\libconcept{forward_range}@ R, class T, class Proj = identity> |
| 3548 | + requires @\libconcept{indirect_binary_predicate}@<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*> |
| 3549 | + constexpr borrowed_subrange_t<R> ranges::find_last(R&& r, const T& value, Proj proj = {}); |
| 3550 | +template<@\libconcept{forward_iterator}@ I, @\libconcept{sentinel_for}@<I> S, class Proj = identity, |
| 3551 | + @\libconcept{indirect_unary_predicate}@<projected<I, Proj>> Pred> |
| 3552 | + constexpr subrange<I> ranges::find_last_if(I first, S last, Pred pred, Proj proj = {}); |
| 3553 | +template<@\libconcept{forward_range}@ R, class Proj = identity, |
| 3554 | + @\libconcept{indirect_unary_predicate}@<projected<iterator_t<R>, Proj>> Pred> |
| 3555 | + constexpr borrowed_subrange_t<R> ranges::find_last_if(R&& r, Pred pred, Proj proj = {}); |
| 3556 | +template<@\libconcept{forward_iterator}@ I, @\libconcept{sentinel_for}@<I> S, class Proj = identity, |
| 3557 | + @\libconcept{indirect_unary_predicate}@<projected<I, Proj>> Pred> |
| 3558 | + constexpr subrange<I> ranges::find_last_if_not(I first, S last, Pred pred, Proj proj = {}); |
| 3559 | +template<@\libconcept{forward_range}@ R, class Proj = identity, |
| 3560 | + @\libconcept{indirect_unary_predicate}@<projected<iterator_t<R>, Proj>> Pred> |
| 3561 | + constexpr borrowed_subrange_t<R> ranges::find_last_if_not(R&& r, Pred pred, Proj proj = {}); |
| 3562 | +\end{itemdecl} |
| 3563 | + |
| 3564 | +\begin{itemdescr} |
| 3565 | +\pnum |
| 3566 | +Let $E$ be: |
| 3567 | +\begin{itemize} |
| 3568 | +\item |
| 3569 | +\tcode{bool(invoke(proj, *i) == value)} for \tcode{ranges::find_last}; |
| 3570 | +\item |
| 3571 | +\tcode{bool(invoke(pred, invoke(proj, *i)))} for \tcode{ranges::find_last_if}; |
| 3572 | +\item |
| 3573 | +\tcode{bool(!invoke(pred, invoke(proj, *i)))} for \tcode{ranges::find_last_if_not}. |
| 3574 | +\end{itemize} |
| 3575 | + |
| 3576 | +\pnum |
| 3577 | +\returns |
| 3578 | +Let \tcode{i} be the last iterator in the range \range{first}{last} |
| 3579 | +for which $E$ is \tcode{true}. |
| 3580 | +Returns \tcode{\{i, last\}}, or |
| 3581 | +\tcode{\{last, last\}} if no such iterator is found. |
| 3582 | + |
| 3583 | +\pnum |
| 3584 | +\complexity |
| 3585 | +At most \tcode{last - first} applications of |
| 3586 | +the corresponding predicate and projection. |
| 3587 | +\end{itemdescr} |
| 3588 | + |
3517 | 3589 | \rSec2[alg.find.end]{Find end}
|
3518 | 3590 |
|
3519 | 3591 | \indexlibraryglobal{find_end}%
|
|
0 commit comments