406. vector::insert(s) exception safety

Section: 23.3.11.5 [vector.modifiers] Status: CD1 Submitter: Dave Abrahams Opened: 2003-04-27 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [vector.modifiers].

View all issues with CD1 status.

Discussion:

There is a possible defect in the standard: the standard text was never intended to prevent arbitrary ForwardIterators, whose operations may throw exceptions, from being passed, and it also wasn't intended to require a temporary buffer in the case where ForwardIterators were passed (and I think most implementations don't use one). As is, the standard appears to impose requirements that aren't met by any existing implementation.

Proposed resolution:

Replace 23.3.11.5 [vector.modifiers] paragraph 1 with:

1- Notes: Causes reallocation if the new size is greater than the old capacity. If no reallocation happens, all the iterators and references before the insertion point remain valid. If an exception is thrown other than by the copy constructor or assignment operator of T or by any InputIterator operation there are no effects.

[We probably need to say something similar for deque.]