Can anyone explain what an iterator is??
Can anyone explain what an iterator is??
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
There are also input stream iterators that make filling/displaying containers much easier.
the word iterator is almost synonymous with the word placeholder. That is, an iterator is used to store a position of an element. (either in a container or a stream)
You may be familiar with the way that a pointer can be used as a 'placeholder' for an element in an array; an iterator is really just a neatly packaged abstraction of that concept. (with built in range checking, so its safer too)
>> with built in range checking, so its safer too
The concept of an iterator does not include range checking, and most STL iterators also do not include built-in range checking.
ah ok, my bad. I was under the impression that STL iterators would throw an out of range exception if you went beyond the container limits. then again, perhaps that's not really range checkingOriginally Posted by Daved
I think the .at() function with strings does that, out of range checking I mean. Not sure about whether vectors have that ...
Vectors have at(), and it throws.
No iterator I've ever seen throws. They might assert(), but they do not throw.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
thanks for the help. I got it.