132. list::resize description uses random access iterators

Section: 26.3.10.3 [list.capacity] Status: TC1 Submitter: Howard Hinnant Opened: 1999-03-06 Last modified: 2016-02-10

Priority: Not Prioritized

View all other issues in [list.capacity].

View all issues with TC1 status.

Discussion:

The description reads:

-1- Effects:

         if (sz > size())
           insert(end(), sz-size(), c);
         else if (sz < size())
           erase(begin()+sz, end());
         else
           ;                           //  do nothing

Obviously list::resize should not be specified in terms of random access iterators.

Proposed resolution:

Change 26.3.10.3 [list.capacity] paragraph 1 to:

Effects:

         if (sz > size())
           insert(end(), sz-size(), c);
         else if (sz < size())
         {
           iterator i = begin();
           advance(i, sz);
           erase(i, end());
         }

[Dublin: The LWG asked Howard to discuss exception safety offline with David Abrahams. They had a discussion and believe there is no issue of exception safety with the proposed resolution.]