std::reverse
and std::copy_if
Section: 26.7.1 [alg.copy], 26.7.10 [alg.reverse] Status: C++14 Submitter: Nikolay Ivchenkov Opened: 2011-03-02 Last modified: 2016-01-28
Priority: Not Prioritized
View other active issues in [alg.copy].
View all other issues in [alg.copy].
View all issues with C++14 status.
Discussion:
In the description of std::reverse
Effects: For each non-negative integer
i <= (last - first)/2
, appliesiter_swap
to all pairs of iteratorsfirst + i
,(last - i) - 1
.
should be changed to
Effects: For each non-negative integer
i < (last - first)/2
, appliesiter_swap
to all pairs of iteratorsfirst + i
,(last - i) - 1
.
Here i
shall be strictly less than (last - first)/2
.
In the description of std::copy_if
Returns paragraph is missing.
[2011-03-02: Daniel drafts wording]
Proposed resolution:
Modify 26.7.10 [alg.reverse] p. 1 as indicated:
1 Effects: For each non-negative integer
i <
, applies=(last - first)/2iter_swap
to all pairs of iteratorsfirst + i
,(last - i) - 1
.
Add the following Returns element after 26.7.1 [alg.copy] p. 9:
template<class InputIterator, class OutputIterator, class Predicate> OutputIterator copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);8 Requires: The ranges
9 Effects: Copies all of the elements referred to by the iterator[first,last)
and[result,result + (last - first))
shall not overlap.i
in the range[first,last)
for whichpred(*i)
is true. ?? Returns: The end of the resulting range. 10 Complexity: Exactlylast - first
applications of the corresponding predicate. 11 Remarks: Stable.