Issue 538: 241 again: Does unique_copy() require CopyConstructible and Assignable? (original) (raw)
This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of CD1 status.
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 of241(i)"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 neitherInputIteratornorOutputIteratormeets the requirements of forward iterator then the value type ofInputIteratormust 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 wantInputIterator::value_type to be both CopyConstructible andCopyAssignable (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 neitherInputIteratornorOutputIteratormeets the requirements of forward iterator then thevalue typevalue_typeofInputIteratormust be CopyConstructible (20.1.3) and Assignable. Otherwise CopyConstructible is not required.