This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++17 status.
Section: 18.104.22.168 [vector.modifiers] Status: C++17 Submitter: Gerard Stone Opened: 2017-01-16 Last modified: 2020-09-06
View all other issues in [vector.modifiers].
View all issues with C++17 status.
In Table 87 (Sequence container requirements) erase(q) and erase(q1, q2) functions have the following requirements:
For vector and deque, T shall be MoveAssignable.
On the other hand, section [vector.modifiers] has the following specification for erase functions (emphasis mine):
Throws: Nothing unless an exception is thrown by the copy constructor, move constructor, assignment operator, or move assignment operator of T.
Note that Table 87 requires T to be only MoveAssignable, it says nothing about T being copy- or move-constructible. It also says nothing about T being CopyInsertable and MoveInsertable, so why is this even there? The only reason might be so that vector could shrink, but in this case T should be required to be MoveInsertable or CopyInsertable into vector.On the other hand, we expect that vector will neither allocate, nor deallocate any memory during this operation, because in Effects it is specified that iterators/references shall be invalidated at or after the point of the erase. So to avoid any confusion, the proposed resolution is to remove mentions of T's copy/move constructors from [vector.modifiers] paragraph 5.
This wording is relative to N4618.
Edit 22.214.171.124 [vector.modifiers] p5 as indicated:
iterator erase(const_iterator position); iterator erase(const_iterator first, const_iterator last); void pop_back();
-3- Effects: Invalidates iterators and references at or after the point of the erase.-4- Complexity: The destructor of T is called the number of times equal to the number of the elements erased, but the assignment operator of T is called the number of times equal to the number of elements in the vector after the erased elements. -5- Throws: Nothing unless an exception is thrown by the
copy constructor, move constructor,assignment operator ,or move assignment operator of T.