2834. Resolution LWG 2223 is missing wording about end iterators

Section: 24.3.2.4 [string.capacity], 26.3.8.3 [deque.capacity], 26.3.11.3 [vector.capacity] Status: C++17 Submitter: Thomas Koeppe Opened: 2016-11-29 Last modified: 2017-07-30

Priority: 0

View other active issues in [string.capacity].

View all other issues in [string.capacity].

View all issues with C++17 status.

Discussion:

The resolution of LWG 2223 added the wording "Reallocation invalidates all the references, pointers, and iterators referring to the elements in the sequence." to a number of shrink_to_fit operations.

This seems to be missing any mention of end iterators. Surely end iterators are invalidated, too?

Suggested resolution:

For string, deque, and vector each, append as follows:

Reallocation invalidates all the references, pointers, and iterators referring to the elements in the sequence as well as the past-the-end iterator.

[2017-01-27 Telecon]

Priority 0

Proposed resolution:

This wording is relative to N4618.

  1. Edit 24.3.2.4 [string.capacity] as indicated:

    void shrink_to_fit();
    

    […]

    -15- Remarks: Reallocation invalidates all the references, pointers, and iterators referring to the elements in the sequence as well as the past-the-end iterator. If no reallocation happens, they remain valid.

  2. Edit 26.3.8.3 [deque.capacity] as indicated:

    void shrink_to_fit();
    

    […]

    -8- Remarks: shrink_to_fit invalidates all the references, pointers, and iterators referring to the elements in the sequence as well as the past-the-end iterator.

  3. Edit 26.3.11.3 [vector.capacity] as indicated:

    void shrink_to_fit();
    

    […]

    -10- Remarks: Reallocation invalidates all the references, pointers, and iterators referring to the elements in the sequence as well as the past-the-end iterator. If no reallocation happens, they remain valid.