Inconsistency of wordings in std::vector::erase() and std::deque::erase()

70 views
Skip to first unread message

Anton Savin

unread,
Feb 2, 2015, 8:27:08 AM2/2/15
to std-dis...@isocpp.org
In the latest draft N4296, and in all drafts up to at least N3337:

[deque.modifiers]/5 (regarding deque::erase()):

Complexity: The number of calls to the destructor is the same as the number of elements erased, but
the number of calls to the assignment operator is no more than the lesser of the number of elements
before the erased elements and the number of elements after the erased elements.

[vector.modifiers]/4 (regarding vector::erase()):
Complexity: The destructor of T is called the number of times equal to the number of the elements
erased, but the move assignment operator of T is called the number of times equal to the number of
elements in the vector after the erased elements.

Is there any reason for explicit mentioning for move assignment for std::vector::erase()?
Shouldn't these two wordings be the same with this regard?

Daniel Krügler

unread,
Mar 2, 2015, 5:33:30 AM3/2/15
to std-dis...@isocpp.org
The wording deviation looks like a defect to me, more specifically I
believe that the restriction to move-assignment for vector::erase() is
wrong. This becomes more obvious when comparing the corresponding
Throws elements, which in both cases refer to "assignment operator, or
move assignment operator of T". I also believe that the Throws
elements should replace the first "assignment operator" by "copy
assignment operator".

Please send a corresponding library issue to the lwgchair address (see
the Reply-To address mentioned in
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html).

Thanks,

- Daniel
Reply all
Reply to author
Forward
0 new messages