Jump to content
  • Advertisement
Sign in to follow this  
Tispe

std::queue::front() Expression: deque iterator not dereferencable

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

Hi. I have a FIFO buffer that acts up when I try to retrieve the front element:

std::shared_ptr<RawFile> spMySmartPointer = MyFIFO.front();    //The error appears here
MyFIFO.pop();

I have an std::queue of shared pointers. When I try to retrieve the front() and pass it down my processing pipeline I get the following run-time error:

 

 

---------------------------

Microsoft Visual C++ Debug Library
---------------------------
Debug Assertion Failed!
 
Program: ...awc\documents\visual studio 2010\Projects\Game\Debug\Game.exe
File: c:\program files (x86)\microsoft visual studio 10.0\vc\include\deque
Line: 338
 
Expression: deque iterator not dereferencable
 
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
 
(Press Retry to debug the application)
---------------------------
Abort   Retry   Ignore   
---------------------------

 

 

What am I doing wrong?

Share this post


Link to post
Share on other sites
Advertisement

Bawww, disregard. I forgot that the FIFO may be empty thus breaking the code.

 

Now I check if its empty() before trying to get front().... smile.png

Edited by Tispe

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!