Title
vector::resize(n, t)'s specification should be simplified
Status
c++14
Section
[vector.capacity] [deque.capacity]
Submitter
Stephan T. Lavavej

Created on 2013-09-21.00:00:00 last changed 130 months ago

Messages

Date: 2014-02-13.06:35:03

Proposed resolution:

This wording is relative to N3691.

  1. Edit [deque.capacity]/4 as indicated:

    void resize(size_type sz, const T& c);
    

    […]

    -4- Requires: T shall be MoveInsertable into *this and CopyInsertable into *this.

  2. Edit [vector.capacity]/16+17 as indicated:

    void resize(size_type sz, const T& c);
    

    […]

    -16- Requires: T shall be MoveInsertable into *this and CopyInsertable into *this.

    -17- Remarks: If an exception is thrown other than by the move constructor of a non-CopyInsertable T there are no effects.

Date: 2014-02-13.06:35:03

[ Issaquah 2014-02-11: Move to Immediate ]

Date: 2013-09-21.00:00:00

First, [deque.capacity]/4 and [vector.capacity]/16 say that resize(size_type sz, const T& c) "Requires: T shall be MoveInsertable into *this and CopyInsertable into *this." The CopyInsertable requirement is correct (because sz might be size() + 2 or more), but the MoveInsertable requirement is redundant due to [container.requirements.general]/13: "T is CopyInsertable into X means that, in addition to T being MoveInsertable into X, the [...]". (LWG 2033's resolution said that this was "not redundant, because CopyInsertable is not necessarily a refinement of MoveInsertable" which was true at the time, but then LWG 2177's resolution made it a refinement.)

Second, [vector.capacity]/17 says "Remarks: If an exception is thrown other than by the move constructor of a non-CopyInsertable T there are no effects." This is confusing because T is required to be CopyInsertable. (/14 says the same thing for resize(size_type sz), where it is correct because that overload requires only MoveInsertable and DefaultInsertable.)

History
Date User Action Args
2014-02-27 17:03:20adminsetstatus: wp -> c++14
2014-02-20 13:52:38adminsetstatus: immediate -> wp
2014-02-13 06:35:03adminsetmessages: + msg6834
2014-02-13 06:35:03adminsetstatus: new -> immediate
2013-10-11 21:09:07adminsetmessages: + msg6714
2013-09-21 00:00:00admincreate