Jump to content
  • Advertisement
Sign in to follow this  
yaustar

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

This topic is 3730 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is the .end() iterator always the same value regardless of the size of an Standard Library container?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!