Adjoints to "Enabling list-initialization for algorithms": find_last

Published Proposal,

ISO/IEC 14882 Programming Languages — C++, ISO/IEC JTC1/SC22/WG21


We extend the same changes that [P2248R8] applied to the rest of the find algorithms to std::ranges::find_last.

1. Changelog

2. Motivation and scope

In the Tokyo 2024 meeting [P2248R8] was adopted. Due to an oversight (which is entirely our fault) std::ranges::find_last was accidentally excluded from the algorithms for which a default template type parameter for the "value" argument was provided.

We propose to modify find_last’s specification, so that it matches the post-P2248 one for the rest of the algorithms (especially find).

3. Proposed Wording

All the proposed changes are relative to [N4971], assuming that [P2248R8]'s wording has been merged already.

Modify [alg.find.last] as shown:

template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity, class T = projected_value_t<I, Proj>>
  requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
    constexpr subrange<I> ranges::find_last(I first, S last, const T& value, Proj proj = {});

template<forward_range R, class T, class Proj = identity, class T = projected_value_t<iterator_t<R>, Proj>>
  requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
    constexpr borrowed_subrange_t<R> ranges::find_last(R&& r, const T& value, Proj proj = {});

4. Acknowledgements

Thanks to Jens Maurer for pointing out this oversight of [P2248R8].

Thanks to KDAB for supporting this work.

All remaining errors are ours and ours only.


Informative References

Thomas Köppe. Working Draft, Programming Languages — C++. 18 December 2023. URL: https://wg21.link/n4971
Giuseppe D'Angelo. Enabling list-initialization for algorithms. URL: https://isocpp.org/files/papers/P2248R8.html