Title
splicing invalidates iterators
Status
cd1
Section
[list.ops]
Submitter
Brian Parker

Created on 2000-07-14.00:00:00 last changed 164 months ago

Messages

Date: 2010-10-21.18:28:33

Rationale:

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

Date: 2010-10-21.18:28:33

[ pre-Copenhagen: Howard provided wording. ]

Date: 2010-10-21.18:28:33

Proposed resolution:

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

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

In [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 [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 [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.

Date: 2000-07-14.00:00:00

Section [list.ops] states that

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

invalidates all iterators and references to list x.

This is unnecessary and defeats an important feature of splice. In fact, the SGI STL guarantees that iterators to x remain valid after splice.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg2006
2010-10-21 18:28:33adminsetmessages: + msg2005
2010-10-21 18:28:33adminsetmessages: + msg2004
2000-07-14 00:00:00admincreate