Sign in to follow this  

vector iterator not dereferencable

Recommended Posts

lride    674
I have this piece of code. This is called once every frame
[source lang="cpp"] //While there is a message to deliver
while(<=currentTime && !messageQueue.empty())
//deliver the message>handleMessage(;
//delete the message

This works fine in release, but when I run in debug mode, I soon get an assertion failure: "Debug Assertion Failed! vector iterator not dereferencable" Edited by lride

Share this post

Link to post
Share on other sites
JTippetts    12970
You should put the !messageQueue.empty() test before you attempt to dereference top(), in case the queue actually is empty which would mean that is trying to dereference end() iterator.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this