Movatterモバイル変換


[0]ホーム

URL:



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

250. splicing invalidates iterators

Section: 23.3.11.5[list.ops]Status:CD1Submitter: Brian ParkerOpened: 2000-07-14Last modified: 2016-01-28

Priority:Not Prioritized

View all otherissues in [list.ops].

View all issues withCD1 status.

Discussion:

Section 23.3.11.5[list.ops] states that

  void splice(iterator position, list<T, Allocator>& x);

invalidates all iterators and references to listx.

This is unnecessary and defeats an important feature of splice. Infact, the SGI STL guarantees that iterators tox remain validaftersplice.

Proposed resolution:

Add a footnote to 23.3.11.5[list.ops], paragraph 1:

[Footnote: As specified in [default.con.req], paragraphs4-5, the semantics described in this clause applies only to the casewhere allocators compare equal. --end footnote]

In 23.3.11.5[list.ops], replace paragraph 4 with:

Effects: Inserts the contents of x before position and x becomes empty. Pointers and references to the moved elements of x now refer to those same elements but as members of *this. Iterators referring to the moved elements will continue to refer to their elements, but they now behave as iterators into *this, not into x.

In 23.3.11.5[list.ops], replace paragraph 7 with:

Effects: Inserts an element pointed to by i from list x before position and removes the element from x. The result is unchanged if position == i or position == ++i. Pointers and references to *i continue to refer to this same element but as a member of *this. Iterators to *i (including i itself) continue to refer to the same element, but now behave as iterators into *this, not into x.

In 23.3.11.5[list.ops], replace paragraph 12 with:

Requires: [first, last) is a valid range in x. The result is undefined if position is an iterator in the range [first, last). Pointers and references to the moved elements of x now refer to those same elements but as members of *this. Iterators referring to the moved elements will continue to refer to their elements, but they now behave as iterators into *this, not into x.

[pre-Copenhagen: Howard provided wording.]

Rationale:

The original proposed resolution said that iterators and referenceswould remain "valid". The new proposed resolution clarifies what thatmeans. Note that this only applies to the case of equal allocators.From [default.con.req] paragraph 4, the behavior of list whenallocators compare nonequal is outside the scope of the standard.


[8]ページ先頭

©2009-2026 Movatter.jp