Jump to content
  • Advertisement
Sign in to follow this  
Gaiiden

Validating iterators

This topic is 5457 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

When I was using VC++ 6, this line was fine
if ((m_CurrentAnimation != 0) && (m_CurrentAnimation->second->m_bPlaying))
Now, however, VC++ Express doesn't seem to like it at all. It gives me an error for trying to check to make sure that m_CurrentAnimation is actually a valid iterator of std::map<string, *AnimObj>. I can't even do
if (m_CurrentAnimation)
without it bitching at me. So my question is what do I do now to make sure I'm about to access a valid iterator? I suppose I could create a flag that lets me know when I have an animation assigned to the iterator, but I'd rather be able to still check it directly.

Share this post


Link to post
Share on other sites
Advertisement
You cannot. STL doesn't provide a way to ensure the validity of iterators, in 2005 or elsewhere. Commonly, however, container.end() is used as an "invalid" iterator (not always useful when that iterator may change, tho).

Share this post


Link to post
Share on other sites
Bah. I'll just have to make sure when I unload an animation to set the iterator to the end of the container then. Thanks anyways...

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!