On Jan 6, 6:28 pm, Jorgen Grahn <grahn+n...@snipabacken.se> wrote:
On Thu, 2011-01-06, Marcel M ller wrote:
Yes, and according to the guarantees of std::list it will
always point to one past the last element in the container.
That's an interesting assertion. I don't think that the
standard is clear here: does the end iterator point to one past
the last element, always, or does it point to one past the last
element when it was called. I.e.:
std::list<char> l;
l.push_back('a');
l.push_back('b');
l.push_back('c');
std::list<char>::iterator i = l.end();
// i points to one past the element 'c'
l.push_back('d');
// i points to one past the element 'c'?
// or one past the new last element.
I don't think that the standard is really clear here. (I don't
think it's an issue for other containers---in vector, for
example, insertion invalidates any iterators behind the point of
insertion, and thus, any end iterator.)
Interesting subject. You are not entirely right, as the iterators will
stay valid so long as the vector has sufficient capacity.