Possible Duplicate:
comparing iterators from different containers
In practice, std::vector<T>::iterator
is probably implemented as a wrapped T*
on most STL implementations, so every iterator is associated with a unique memory address (assuming the iterator comes from a non-empty vector).
However, that's an implementation detail. Is there any actual guarantee from the C++ standard that every vector iterator is somehow unique? Specifically, can the end()
iterator of one non-empty vector ever equal the end()
iterator of another non-empty vector?
For example:
std::vector<int> v1;
std::vector<int> v2;
/* Fill both vectors with values... */
assert(v1.end() != v2.end()); // Does C++ guarantee this assertion will succeed?