This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of NAD status.

3596. ranges::starts_with and ranges::ends_with are underspecified

Section: 26.6.16 [alg.starts.with], 26.6.17 [alg.ends.with] Status: NAD Submitter: Michael Schellenberger Costa Opened: 2021-09-17 Last modified: 2021-09-24

Priority: Not Prioritized

View all issues with NAD status.

Discussion:

When implementing C++23 new ranges::starts_with and ranges::ends_with for MSVC we came around some issues regarding infinite ranges.

In short, there is no possible answers to ends_with, if the second range is infinite. Similarly, there is no meaningful answer to starts_with if both ranges are infinite.

We should constraint both algorithms to forbid those corner cases (preferred resolution), or explicitly specify a given return value for those (The reasonable choice would be "return false;")

[2021-09-24 infinite ranges are invalid by [iterator.requirements.general] p10, so undefined by p12. Might be nice to relax this in future, but needs a paper. Status changed: New → NAD.]

Proposed resolution: