Movatterモバイル変換


[0]ホーム

URL:



This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++17 status.

2127. Move-construction withraw_storage_iterator

Section: 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.

Dave Abrahams:

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.

  1. 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);};}
  2. 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 signatureT shall beCopyConstructible. Forthe second signatureT shall beMoveConstructible.

    -4-Effects: Constructs a value fromelement at 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.

  1. 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);};}
  2. Insert a new paragraph before p4:

    raw_storage_iterator<OutputIterator,T>& operator=(const T& element);

    -?-Requires:T shall beCopyConstructible.

    -4-Effects: Constructs a value fromelement at the location to which the iterator points.

    -5-Returns: A reference to the iterator.

  3. Insert the new signature and a new paragraph after p5:

    raw_storage_iterator<OutputIterator,T>& operator=(T&& element);

    -?-Requires:T shall beMoveConstructible.

    -?-Effects: Constructs a value fromstd::move(element) at thelocation to which the iterator points.

    -?-Returns: A reference to the iterator.


[8]ページ先頭

©2009-2026 Movatter.jp