Quote Originally Posted by wysota View Post
Deleting the pointed item invalidates the iterator. So does addition in certain cases.

My point is that the iterator/container/whatever can only work on const objects. And you can't modify those.
Modification doesn't regard only creation and deletion. There is also modification which doesn't invalidate iterators. Anyway, *this was not the point* and you went on another topic. The point was: if you use iterators for filtering, and data is highly mutable (NOT while iterating), then caching is useless and iterators are Ok to use.

Quote Originally Posted by wysota View Post
Yeah, I call them generators If something generates something then it is a generator. If you want to iterate over a generator, that's fine but the iterator iterates, not generates, if you ask me. I know it's just a matter of taxonomy but still.
Probably you didn't read well what I wrote OR I expressed badly. I said:

I think that in case of "infinite iterators", for example when data is generated from external devices, network or pipelined algorithm, containers would be pointless.
I didn't say that iterators were used to generate data (and I thought that was obvious). A stream is not an iterator, but is an infinite source of data. I was talking about using iterators OVER an infinite collection of data, and as you say: "if you want to iterate over a generator, that's fine". And that was the point of my statement in first place.

Quote Originally Posted by wysota View Post
If it has end() defined, then it is finite. Otherwise I hate to be in a skin of a person trying to process every element of such collection.
I don't agree. You're assuming that we are talking about STL-style iterators, which uses begin() and end(). Java-style iterators, for example, checks using "hasNext()" and not testing if they reached a defined end. That method could return true to give an infinite iterator.
In addition, I think that the semantic of the "end" method in STL iterators is NOT do define a length of a container, but to define a case in which has no longer sense to go on (which is very very different from saying that the iterator will find an end).
It's easy to build a circular list with >0 elements which will iterate forever, even if the end() is defined.
~Aki