Created on 2010-06-25.00:00:00 last changed 161 months ago
Proposed resolution:
template<class ForwardIterator1, class ForwardIterator2> ForwardIterator1 search(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2); template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> ForwardIterator1 search(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);1 - [...]
2 - Returns: The first iterator i in the range [first1,last1 - (last2-first2)) such that for any nonnegative integer n less than last2 - first2 the following corresponding conditions hold: *(i + n) == *(first2 + n), pred(*(i + n), *(first2 + n)) != false. Returns first1 if [first2,last2) is emptyor, otherwise returns last1 if no such iterator is found.
[ Adopted at 2010-11 Batavia ]
[ Post-Rapperswil ]
It was verified that none of the remaining possibly affected algorithms does have any similar problems and a concrete P/R was added that used a similar style as has been applied to the other cases.
Moved to Tentatively Ready after 5 positive votes on c++std-lib.
LWG 1205 (currently in WP) clarified the return value of several algorithms when dealing with empty ranges. In particular it recommended for [alg.search]:
template<class ForwardIterator1, class ForwardIterator2> ForwardIterator1 search(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2); template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> ForwardIterator1 search(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);1 Effects: ...
2 Returns: ... Returns last1 if no such iterator is found.
3 Remarks: Returns first1 if [first2,last2) is empty.
Unfortunately this got translated to an incorrect specification for what gets returned when no such iterator is found (N3092):
template<class ForwardIterator1, class ForwardIterator2> ForwardIterator1 search(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2); template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> ForwardIterator1 search(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);1 Effects: ...
2 Returns: ... Returns first1 if [first2,last2) is empty or if no such iterator is found.
LWG 1205 is correct and N3092 is not equivalent nor correct.
I have not reviewed the other 10 recommendations of 1205.
History | |||
---|---|---|---|
Date | User | Action | Args |
2011-08-23 20:07:26 | admin | set | status: wp -> c++11 |
2010-11-24 14:01:03 | admin | set | messages: + msg5426 |
2010-11-14 13:10:57 | admin | set | status: voting -> wp |
2010-11-08 14:14:39 | admin | set | status: ready -> voting |
2010-10-21 19:06:53 | admin | set | messages: + msg4776 |
2010-10-21 19:06:53 | admin | set | status: new -> ready |
2010-10-21 18:28:33 | admin | set | messages: + msg1632 |
2010-06-25 00:00:00 | admin | create |