C++: Is the .end() iterator always the same value?

Started by
2 comments, last by yaustar 15 years, 8 months ago
Is the .end() iterator always the same value regardless of the size of an Standard Library container?

Steven Yau
[Blog] [Portfolio]

Advertisement
No. std::vector::end(), for example, points one past the last element. This location changes depending on the number of items in the container and the address of the allocated memory.
Ra
If I'm not mistaken you can only compare iterators that belong to the same container. You can't compare a.begin() == b.end(), if that's what you are asking (you can't use the end of one container to check for the end of any other container).
Quote:Original post by Ra
No. std::vector::end(), for example, points one past the last element. This location changes depending on the number of items in the container and the address of the allocated memory.


That's what I thought, cheers.

Steven Yau
[Blog] [Portfolio]

This topic is closed to new replies.

Advertisement