Re:Ask HN: How do you "fix" the curse of the gifted?
by pcowans on Sunday February 03, 2013 @03:22PM
(#5160992)
Although I kind of agree with you that iterators for vectors aren't really very necessary, for std::list, std::map, etc. I think they're quite a sensible way of sequentially accessing the data - you'd pretty much have to re-implement them if they didn't exist. In the case of maps, I don't actually think the container implementation is specified enough to allow you to get away with any less abstraction - it technically doesn't have to be a BST, although I guess you could argue that the containers should have mapped to precisely defined data structures in the first place.
C++11's type inference does make STL iterators a lot less ugly, by the way. Also (referring to the initial post), there's no reason you have to use for rather than while when using iterators (while(v != c.end()) ...).
C++11's type inference does make STL iterators a lot less ugly, by the way. Also (referring to the initial post), there's no reason you have to use for rather than while when using iterators (while(v != c.end()) ...).