- check if the iterator can be differentiated. e.g. don't do *iterator.end()
- check if the iterator is still validated. e.g. after inserting or removing elements. it invalidates reference, pointers, and iterators that refer to the following elements
- check if the iterator is in range. e.g. first does not pass end, or itor1 and itor2 should belong to the same container.
- check if operation on iterator does not manipulate the temporary of built in type (c++ does not allow it). e.g. --itor.end() as a function argument(become temporary) might be an error. WHY???
Search This Blog
Friday, May 13, 2011
ExceptionalC++ Fun: 1. iterators
Things to remember:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment