Title
remove_copy/remove_copy_if and Input Iterators
Status
nad
Section
[alg.remove]
Submitter
Anthony Williams

Created on 2002-05-13.00:00:00 last changed 172 months ago

Messages

Date: 2010-10-21.18:28:33

Rationale:

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

Date: 2010-10-21.18:28:33

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 [alg.remove] paragraph 6.

Date: 2002-05-13.00:00:00

remove_copy and remove_copy_if ([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.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg2375
2010-10-21 18:28:33adminsetmessages: + msg2374
2002-05-13 00:00:00admincreate