Iterators Make the Algorithms Container Independent, ...
All but the second step in the find
function can be handled by iterator operations: The iterator dereference operator gives access to an element’s value; if a matching element is found, find
can return an iterator to that element; the iterator increment operator moves to the next element; the “off-the-end” iterator will indicate when find
has reached the end of its given sequence; and find
can return the off-the-end iterator (§ 9.2.1, p. 331) to indicate that the given value wasn’t found.
Get C++ Primer, Fifth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.