This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
Section: 18.104.22.168 [deque.modifiers], 22.214.171.124 [vector.modifiers] Status: New Submitter: Billy O'Neal III Opened: 2019-10-29 Last modified: 2019-11-04
View all other issues in [deque.modifiers].
View all issues with New status.
It seems incorrect that a container would invalidate anything as a result of being asked to erase 0 elements. This came up in a recent customer bug report against Visual Studio, where given a vector v, v.erase(v.begin(), v.begin()) triggered a self-assignment of all the elements in the vector.deque has language enumerating erasures of the first and last element which invalidate fewer iterators, and a fallback that says all iterators are invalidated, which seems to intend to be talking about middle-of-container erasures. However, erasing 0 elements isn't really a middle of container erasure. vector says that iterators and references are invalidated after the 'point of the erase', but when 0 elements are erased it's unclear what that even means. We should say that erasures that erase 0 elements are no ops and be clearer about which elements are invalidated for vector.
[2019-11 Priority to 3 during Monday issue prioritization in Belfast]
This wording is relative to N4835.
Modify 126.96.36.199 [deque.modifiers] as indicated:
iterator erase(const_iterator position); iterator erase(const_iterator first, const_iterator last); void pop_front(); void pop_back();
-4- Effects: An erase operation that erases the last element of a deque invalidates only the past-the-end iterator and all iterators and references to the erased elements. An erase operation that erases the first element of a deque but not the last element invalidates only iterators and references to the erased elements. An erase operation that erases neither the first element nor the last element of a deque invalidates the past-the-end iterator and all iterators and references to all the elements of the deque.[…]
[Note: pop_front and pop_back are erase operations. — end note]
Modify 188.8.131.52 [vector.modifiers] as indicated:
constexpr iterator erase(const_iterator position); constexpr iterator erase(const_iterator first, const_iterator last); constexpr void pop_back();
-3- Effects: Invalidates iterators and references at or after the[…]
point of the erase.