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

367. remove_copy/remove_copy_if and Input Iterators

Section: 23.6.8 [alg.remove] Status: NAD Submitter: Anthony Williams Opened: 2002-05-13 Last modified: 2016-02-10

Priority: Not Prioritized

View all other issues in [alg.remove].

View all issues with NAD status.


remove_copy and remove_copy_if (23.6.8 [alg.remove]) permit their input range to be marked with Input Iterators. However, since two operations are required against the elements to copy (comparison and assigment), when the input range uses Input Iterators, a temporary copy must be taken to avoid dereferencing the iterator twice. This therefore requires the value type of the InputIterator to be CopyConstructible. If the iterators are at least Forward Iterators, then the iterator can be dereferenced twice, or a reference to the result maintained, so the temporary is not required.

Proposed resolution:

Add "If InputIterator does not meet the requirements of forward iterator, then the value type of InputIterator must be copy constructible. Otherwise copy constructible is not required." to 23.6.8 [alg.remove] paragraph 6.


The assumption is that an input iterator can't be dereferenced twice. There's no basis for that assumption in the Standard.