Skip to content

Wrong range in [alg.search] LWG4179 #7474

Closed
@slotosch

Description

@slotosch

During the qualification of the C++ STL Validas has pointed me to the following issue:
The specification of [alg.search] has a wrong range.
Currently the range is "[first1, last1 - (last2 - first2))" (exclusive) but should be "[first1, last1 - (last2 - first2)]" (inclusive).
So please correct the closing ")" to "]". Otherwise the last occurence will not be found.
We observed the issue in C++14 and C++17 and cppreference.com
The implementations do the right thing and work correctly and find even the last occurence.

For example in the list {1, 2, 3, 4, 5} the pattern {4,5} should be found (obviously).
In the case the last element is not included it will not be found.
The attached programm shows that the implementation is working and find the pattern.
rangebug.cpp.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    lwgIssue must be reviewed by LWG.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions