This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++17 status.
raw_storage_iteratorSection: 99 [depr.storage.iterator]Status:C++17Submitter: Jonathan WakelyOpened: 2012-01-23Last modified: 2017-07-30
Priority:3
View all otherissues in [depr.storage.iterator].
View all issues withC++17 status.
Discussion:
Aliaksandr Valialkin pointed out thatraw_storage_iterator only supports constructing a new object from lvalues so cannot be used to construct move-only types:
template <typename InputIterator, typename T>void move_to_raw_buffer(InputIterator first, InputIterator last, T *raw_buffer){ std::move(first, last, std::raw_storage_iterator<T *, T>(raw_buffer));}This could easily be solved by overloadingoperator= for rvalues.
raw_storage_iterator causes exception-safety problems when used with anygeneric algorithm. I suggest leaving it alone and not encouraging its use.[2014-11-11, Jonathan provides improved wording]
In Urbana LWG decided to explicitly say the value is constructed from an rvalue.
Previous resolution from Jonathan [SUPERSEDED]:This wording is relative toN3337.
Add a new signature to the synopsis in [storage.iterator] p1:
namespace std { template <class OutputIterator, class T> class raw_storage_iterator : public iterator<output_iterator_tag,void,void,void,void> { public: explicit raw_storage_iterator(OutputIterator x); raw_storage_iterator<OutputIterator,T>& operator*(); raw_storage_iterator<OutputIterator,T>& operator=(const T& element);raw_storage_iterator<OutputIterator,T>& operator=(T&& element); raw_storage_iterator<OutputIterator,T>& operator++(); raw_storage_iterator<OutputIterator,T> operator++(int);};}Insert the new signature and a new paragraph before p4:
raw_storage_iterator<OutputIterator,T>& operator=(const T& element);raw_storage_iterator<OutputIterator,T>& operator=(T&& element);-?-Requires: For the first signature
-4-Effects: Constructs a value fromTshall beCopyConstructible. Forthe second signatureTshall beMoveConstructible.elementat the location to which the iterator points.-5-Returns: A reference to the iterator.
[2015-05, Lenexa]
MC: Suggestion to move it to Ready for incorporation on Friday
MC: move to ready: in favor: 12, opposed: 0, abstain: 3
Proposed resolution:
This wording is relative toN4140.
Add a new signature to the synopsis in [storage.iterator] p1:
namespace std { template <class OutputIterator, class T> class raw_storage_iterator : public iterator<output_iterator_tag,void,void,void,void> { public: explicit raw_storage_iterator(OutputIterator x); raw_storage_iterator<OutputIterator,T>& operator*(); raw_storage_iterator<OutputIterator,T>& operator=(const T& element);raw_storage_iterator<OutputIterator,T>& operator=(T&& element); raw_storage_iterator<OutputIterator,T>& operator++(); raw_storage_iterator<OutputIterator,T> operator++(int);};}Insert a new paragraph before p4:
raw_storage_iterator<OutputIterator,T>& operator=(const T& element);-?-Requires:
-4-Effects: Constructs a value fromTshall beCopyConstructible.elementat the location to which the iterator points.-5-Returns: A reference to the iterator.
Insert the new signature and a new paragraph after p5:
raw_storage_iterator<OutputIterator,T>& operator=(T&& element);-?-Requires:
-?-Effects: Constructs a value fromTshall beMoveConstructible.std::move(element)at thelocation to which the iterator points.-?-Returns: A reference to the iterator.