This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++14 status.

### 2110. `remove` can't swap but note says it might

Section: 25.7.8 [alg.remove] Status: C++14 Submitter: Howard Hinnant Opened: 2011-12-07 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [alg.remove].

View all issues with C++14 status.

Discussion:

25.7.8 [alg.remove]/p1 says:

> 1 Requires: The type of `*first` shall satisfy the `MoveAssignable` requirements (Table 22).

This means that `remove`/`remove_if` can only use move assignment to permute the sequence. But then 25.7.8 [alg.remove]/p6 (non-normatively) contradicts p1:

> 6 Note: each element in the range `[ret,last)`, where `ret` is 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 use `swap` if it is available, but there is no interest. Accept the proposed resolution as written.

[2012, Portland: applied to WP]

Proposed resolution:

This wording is relative to the FDIS.

Change 25.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)`, where `ret` is 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.