This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++17 status.

2834. Resolution LWG 2223 is missing wording about end iterators

Section: 27.4.3.5 [string.capacity], 23.3.5.3 [deque.capacity], 23.3.11.3 [vector.capacity] Status: C++17 Submitter: Thomas Koeppe Opened: 2016-11-29 Last modified: 2020-09-06

Priority: 0

View all other issues in [string.capacity].

View all issues with C++17 status.

Discussion:

The resolution of LWG 2223(i) 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 27.4.3.5 [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 23.3.5.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 23.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.