Title
Inconsistency of wordings in std::vector::erase() and std::deque::erase()
Status
c++17
Section
[deque.modifiers][vector.modifiers]
Submitter
Anton Savin

Created on 2015-03-03.00:00:00 last changed 81 months ago

Messages

Date: 2015-05-07.19:30:46

Proposed resolution:

This wording is relative to N4296.

  1. Change [deque.modifiers]/5 to:

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

  2. Change [vector.modifiers]/4 to:

    -4- 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.

Date: 2015-05-07.19:30:46

[ 2015-05, Lenexa ]

Move to Immediate.

Date: 2015-04-02.17:25:24

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 of move assignment for std::vector::erase()? Shouldn't these two wordings be the same with this regard?

Also, for std::deque, it's not clear from the text which destructors and assignment operators are called.

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2015-10-27 16:52:45adminsetstatus: ready -> wp
2015-05-20 14:24:57adminsetstatus: immediate -> ready
2015-05-07 19:30:46adminsetmessages: + msg7369
2015-05-07 19:30:46adminsetstatus: new -> immediate
2015-04-02 17:25:24adminsetmessages: + msg7308
2015-03-03 00:00:00admincreate