538. 241 again: Does unique_copy() require CopyConstructible and Assignable?

Section: 26.7.9 [alg.unique] Status: CD1 Submitter: Howard Hinnant Opened: 2006-02-09 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [alg.unique].

View all issues with CD1 status.

Discussion:

I believe I botched the resolution of 241 "Does unique_copy() require CopyConstructible and Assignable?" which now has WP status.

This talks about unique_copy requirements and currently reads:

-5- Requires: The ranges [first, last) and [result, result+(last-first)) shall not overlap. The expression *result = *first shall be valid. If neither InputIterator nor OutputIterator meets the requirements of forward iterator then the value type of InputIterator must be CopyConstructible (20.1.3). Otherwise CopyConstructible is not required.

The problem (which Paolo discovered) is that when the iterators are at their most restrictive (InputIterator, OutputIterator), then we want InputIterator::value_type to be both CopyConstructible and CopyAssignable (for the most efficient implementation). However this proposed resolution only makes it clear that it is CopyConstructible, and that one can assign from *first to *result. This latter requirement does not necessarily imply that you can:

*first = *first;

Proposed resolution:

-5- Requires: The ranges [first, last) and [result, result+(last-first)) shall not overlap. The expression *result = *first shall be valid. If neither InputIterator nor OutputIterator meets the requirements of forward iterator then the value type value_type of InputIterator must be CopyConstructible (20.1.3) and Assignable. Otherwise CopyConstructible is not required.