how would you check if the iterator that was returned by the function points to something in container class?
A:
You can't. Make sure you return a valid iterator.
Well I suppose you could by iterating through the container and checking to see if the iterators are equal. But that would be horrid.
John Dibling
2010-02-04 02:04:15
+1
A:
Iterators are passed around as [begin,end) pairs, with the end value signifying "not found" or other forms of the empty sequence. Return that from your function, or return a pair<bool,iterator>
(or similar).
Roger Pate
2010-02-04 02:09:54