find_end
Section: 26.6.8 [alg.find.end] Status: C++14 Submitter: Andrew Koenig Opened: 2012-03-28 Last modified: 2016-01-28
Priority: Not Prioritized
View all issues with C++14 status.
Discussion:
26.6.8 [alg.find.end] describes the behavior of find_end as returning:
The last iterator
i
in the range[first1,last1 - (last2 - first2))
such that for any nonnegative integern < (last2 - first2)
, the following corresponding conditions hold:*(i + n) == *(first2 + n), pred(*(i + n), *(first2 + n)) != false
.
Does "for any" here mean "for every" or "there exists a"? I think it means the former, but it could be interpreted either way.
Daniel: The same problem exists for the following specifications from Clause 26 [algorithms]:[2013-04-20, Bristol]
Unanimous agreement on the wording.
Resolution: move to tentatively ready[2013-09-29, Chicago]
Apply to Working Paper
Proposed resolution:
This wording is relative to N3376.
Change 26.6.8 [alg.find.end] p2 as indicated:
template<class ForwardIterator1, class ForwardIterator2> ForwardIterator1 find_end(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2); template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> ForwardIterator1 find_end(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);[…]
-2- Returns: The last iteratori
in the range[first1,last1 - (last2 - first2))
such that foranyevery nonnegative integern < (last2 - first2)
, the following corresponding conditions hold:*(i + n) == *(first2 + n), pred(*(i + n), *(first2 + n)) != false
. Returnslast1
if[first2,last2)
is empty or if no such iterator is found.
Change 26.6.15 [alg.search] p2 and p6 as indicated:
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);[…]
-2- Returns: The first iteratori
in the range[first1,last1 - (last2-first2))
such that foranyevery nonnegative integern
less thanlast2 - first2
the following corresponding conditions hold:*(i + n) == *(first2 + n), pred(*(i + n), *(first2 + n)) != false
. Returnsfirst1
if[first2,last2)
is empty, otherwise returnslast1
if no such iterator is found.
[…]
template<class ForwardIterator, class Size, class T> ForwardIterator search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value); template<class ForwardIterator, class Size, class T, class BinaryPredicate> ForwardIterator search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value, BinaryPredicate pred);[…]
-6- Returns: The first iteratori
in the range[first,last-count)
such that foranyevery non-negative integern
less thancount
the following corresponding conditions hold:*(i + n) == value, pred(*(i + n),value) != false
. Returnslast
if no such iterator is found.
Change 26.7.10 [alg.reverse] p4 as indicated:
template<class BidirectionalIterator, class OutputIterator> OutputIterator reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);[…]
-4- Effects: Copies the range[first,last)
to the range[result,result+(last-first))
such that foranyevery non-negative integeri < (last - first)
the following assignment takes place:*(result + (last - first) - i) = *(first + i)
.
Change 26.8.5 [alg.partitions] p5 and p9 as indicated:
template<class ForwardIterator, class Predicate> ForwardIterator partition(ForwardIterator first, ForwardIterator last, Predicate pred);[…]
-5- Returns: An iteratori
such that foranyevery iteratorj
in the range[first,i) pred(*j) != false
, and foranyevery iteratork
in the range[i,last), pred(*k) == false
.
[…]
template<class BidirectionalIterator, class Predicate> BidirectionalIterator stable_partition(BidirectionalIterator first, BidirectionalIterator last, Predicate pred);[…]
-9- Returns: An iteratori
such that foranyevery iteratorj
in the range[first,i), pred(*j) != false
, and foranyevery iteratork
in the range[i,last), pred(*k) == false
. The relative order of the elements in both groups is preserved.
Change 26.8 [alg.sorting] p5 as indicated:
-5- A sequence is sorted with respect to a comparator
comp
if foranyevery iteratori
pointing to the sequence andanyevery non-negative integern
such thati + n
is a valid iterator pointing to an element of the sequence,comp(*(i + n), *i) == false
.
Change 26.8.3 [alg.nth.element] p1 as indicated:
template<class RandomAccessIterator> void nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last); template<class RandomAccessIterator, class Compare> void nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);-1- After
nth_element
the element in the position pointed to bynth
is the element that would be in that position if the whole range were sorted. Also foranyevery iteratori
in the range[first,nth)
andanyevery iteratorj
in the range[nth,last)
it holds that:!(*i > *j)
orcomp(*j, *i) == false
.
Change 26.8.4.2 [lower.bound] p2 as indicated:
template<lass ForwardIterator, class T> ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last, const T& value); template<class ForwardIterator, class T, class Compare> ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);[…]
-2- Returns: The furthermost iteratori
in the range[first,last]
such that foranyevery iteratorj
in the range[first,i)
the following corresponding conditions hold:*j < value
orcomp(*j, value) != false
.
Change 26.8.4.3 [upper.bound] p2 as indicated:
template<lass ForwardIterator, class T> ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last, const T& value); template<class ForwardIterator, class T, class Compare> ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);[…]
-2- Returns: The furthermost iteratori
in the range[first,last]
such that foranyevery iteratorj
in the range[first,i)
the following corresponding conditions hold:!(value < *j)
orcomp(value, *j) == false
.
Change 26.8.9 [alg.min.max] p21 and p23 as indicated:
template<class ForwardIterator> ForwardIterator min_element(ForwardIterator first, ForwardIterator last); template<class ForwardIterator, class Compare> ForwardIterator min_element(ForwardIterator first, ForwardIterator last, Compare comp);-21- Returns: The first iterator
i
in the range[first,last)
such that foranyevery iteratorj
in the range[first,last)
the following corresponding conditions hold:!(*j < *i)
orcomp(*j, *i) == false
. Returnslast
iffirst == last
.
[…]
template<class ForwardIterator> ForwardIterator max_element(ForwardIterator first, ForwardIterator last); template<class ForwardIterator, class Compare> ForwardIterator max_element(ForwardIterator first, ForwardIterator last, Compare comp);-23- Returns: The first iterator
i
in the range[first,last)
such that foranyevery iteratorj
in the range[first,last)
the following corresponding conditions hold:!(*i < *j)
orcomp(*i, *j) == false
. Returnslast
iffirst == last
.