This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++14 status.
remove can't swap but note says it mightSection: 26.7.8[alg.remove]Status:C++14Submitter: Howard HinnantOpened: 2011-12-07Last modified: 2016-01-28
Priority:Not Prioritized
View all otherissues in [alg.remove].
View all issues withC++14 status.
Discussion:
26.7.8[alg.remove]/p1 says:
1Requires: The type of
*firstshall satisfy theMoveAssignablerequirements (Table 22).
This means thatremove/remove_if can only use move assignment to permute the sequence. But then 26.7.8[alg.remove]/p6 (non-normatively) contradicts p1:
6Note: each element in the range
[ret,last), whereretis the returned value, has a valid but unspecified state, because the algorithms can eliminate elements by swapping with or moving from elements that were originally in that range.
[2012, Kona]
Move to Ready.
Alisdair notes we could extend permission to useswap if it is available, but thereis no interest. Accept the proposed resolution as written.
[2012, Portland: applied to WP]
Proposed resolution:
This wording is relative to the FDIS.
Change 26.7.8[alg.remove] as indicated:
template<class ForwardIterator, class T> ForwardIterator remove(ForwardIterator first, ForwardIterator last, const T& value);template<class ForwardIterator, class Predicate> ForwardIterator remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);[…]
-6-Note: each element in the range[ret,last), whereretis the returned value, has a valid but unspecified state, because the algorithms can eliminate elements byswapping with ormoving from elements that were originally in that range.