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.
erase
in [vector.modifiers]Section: 23.3.11.5 [vector.modifiers] Status: C++17 Submitter: Gerard Stone Opened: 2017-01-16 Last modified: 2020-09-06
Priority: 0
View all other issues in [vector.modifiers].
View all issues with C++17 status.
Discussion:
In Table 87 (Sequence container requirements) erase(q)
and erase(q1, q2)
functions have the following requirements:
For
vector
anddeque
,T
shall beMoveAssignable
.
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
.
T
's copy/move constructors
from [vector.modifiers] paragraph 5.
[2017-01-27 Telecon]
Priority 0
Proposed resolution:
This wording is relative to N4618.
Edit 23.3.11.5 [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 ofT
is called the number of times equal to the number of the elements erased, but the assignment operator ofT
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 thecopy constructor, move constructor,assignment operator,or move assignment operator ofT
.