Skip to main content
GameDev.net gamedev.net
🔒 Locked

Validating iterators

Started by Gaiiden Oct 11, 2004 at 11:43 PM 1 replies 800+ views
Original Post
Gaiiden
Gaiiden
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. 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.
Drew Sikora
Executive Producer
GameDev.net
Sneftel
Sneftel
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).
Gaiiden
Gaiiden
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...
Drew Sikora
Executive Producer
GameDev.net

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.