From: Chris Uzdavinis (chris_at_[hidden])
Date: 2005-02-09 15:36:21
Doug Gregor <dgregor_at_[hidden]> writes:
> No, it is not legal to compare iterators from different
> containers. Operations that require two iterators mandate that the
> iterators be part of the operation's "domain". Iterators from
> different containers can never be in the same domain.
I generally agree, but think it gets a bit murky when we deal with
std::list iterators, since they can be spliced back and forth between
different containers without being invalidated.
It seems strange that we can compare the two iterators into a list and
that's valid. Then splice one element into another list--the
iterators have not changed whatsoever--but now comparing them is
Finally, splice the remaining element from the first list into the
second, so they're both in the other list now. Presto, comparing the
same two iterators is valid again.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk