Created on 2013-08-15.00:00:00 last changed 136 months ago
Proposed resolution:
This wording is relative to N3691.
Modify [forwardlist.ops] p6 as indicated:
void splice_after(const_iterator position, forward_list& x, const_iterator i); void splice_after(const_iterator position, forward_list&& x, const_iterator i);[…]
-6- Effects: Inserts the element following i into *this, following position, and removes it from x. The result is unchanged if &x == this and the following condition is satisfied: position == i or position == ++i. Pointers and references to *++i continue to refer to the same element but as a member of *this. Iterators to *++i continue to refer to the same element, but now behave as iterators into *this, not into x.
Modify [list.ops] p7 as indicated:
void splice(const_iterator position, list& x, const_iterator i); void splice(const_iterator position, list&& x, const_iterator i);-7- Effects: Inserts an element pointed to by i from list x before position and removes the element from x. The result is unchanged if &x == this and the following condition is satisfied: 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.
[ 2013-09 Chicago (late night issues) ]
Moved to NAD.
The condition under which the list is unchanged is not program code, so there is no undefined behavior to protect against. Rather, the precondition that the evaluation can be performed is implicit if determining when the condition applies.
I think that the effects of list::splice function should be stated more carefully.
Function transferring a single element is described now in the following way ([list.ops] p7):void splice(const_iterator position, list& x, const_iterator i); void splice(const_iterator position, list&& x, const_iterator i);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.
But it is incorrect to talk about operator== for iterators that are not from the same container (after acceptance of N3066, [forward.iterators] p2). So, the text operates with an undefined behaviour.
One is formally allowed to have list implementation where two iterators from different lists return true to operator==. For example, this can only happen to non-dereferenceable iterators, and position and ++i can be non-dereferenceable. So, literally according to the standard, it is not allowed in this implementation to transfer such elements with splice function.
History | |||
---|---|---|---|
Date | User | Action | Args |
2013-09-26 11:12:18 | admin | set | messages: + msg6630 |
2013-09-26 11:12:18 | admin | set | status: new -> nad |
2013-08-20 19:41:21 | admin | set | messages: + msg6564 |
2013-08-15 00:00:00 | admin | create |