Namespaces
Variants
Views
Actions

Difference between revisions of "Talk:cpp/container/vector/push back"

From cppreference.com
(Created page with "The page contains a major error. It states that no iterators or references are invalidated when the capacity is sufficient to accommodate the new element. This is incorrect. A...")
 
(updated)
Line 1: Line 1:
 
The page contains a major error. It states that no iterators or references are invalidated when the capacity is sufficient to accommodate the new element. This is incorrect. Any insertion operator on a vector always invalidates all iterators and references that refer to the point of insertion and past the point of insertion. For this reason `push_back` always invalidates the `end()` iterator.
 
The page contains a major error. It states that no iterators or references are invalidated when the capacity is sufficient to accommodate the new element. This is incorrect. Any insertion operator on a vector always invalidates all iterators and references that refer to the point of insertion and past the point of insertion. For this reason `push_back` always invalidates the `end()` iterator.
 
[[Special:Contributions/173.11.122.193|173.11.122.193]] 10:45, 5 July 2013 (PDT)
 
[[Special:Contributions/173.11.122.193|173.11.122.193]] 10:45, 5 July 2013 (PDT)
 +
 +
: Thanks for the note, I believe you are correct.  I've updated the page to reflect that the past-the-end iterator is invalidated. --[[User:Nate|Nate]] 19:00, 5 July 2013 (PDT)

Revision as of 18:00, 5 July 2013

The page contains a major error. It states that no iterators or references are invalidated when the capacity is sufficient to accommodate the new element. This is incorrect. Any insertion operator on a vector always invalidates all iterators and references that refer to the point of insertion and past the point of insertion. For this reason `push_back` always invalidates the `end()` iterator. 173.11.122.193 10:45, 5 July 2013 (PDT)

Thanks for the note, I believe you are correct. I've updated the page to reflect that the past-the-end iterator is invalidated. --Nate 19:00, 5 July 2013 (PDT)