I am working with an STL list and keep getting errors while attempting to retrieve the last element. I have a class
class Buffer {
private:
list<Flit*> fifo;
...
public:
...
Flit *peek_last_flit(void) const;
...
};
and the implementation
Flit *Buffer::peek_last_flit(void) const {
if (fifo.empty())
return 0;
Flit *f = *(fifo.begin());
return f;
}
I have a similar implementation that returns the head of the list.
Flit *Buffer::peek_flit(void) const {
if (fifo.empty())
return 0;
Flit *f = *(fifo.begin());
return f;
}
How may I approach this issue(I am calling both procedures but when I call Peek_last_flit I get a debug asserion failure message:
Expression: list iterator not dereferencable.
How can I preserve iterators?
Any help would be much appreciated.
1 Answer