

You can choose this underlying container, and this allows a good deal of flexibility. It provides the safe interface, but uses a different container on the inside.

That all said, std::queue is only an adapter. And if later you find your performance is lacking, it's now easy to add a profiler to your nice, clean code, and find out where the problem is.
#Queue fifo lifo code#
Their code becomes a slop of mush, because they've abandoned all that is good in order to really get nothing out of it.īy writing good, readable code first, most of you performance problems will solve themselves. The reason for this is simple: people who strive for performance before cleanliness and elegance almost always finish last. Firstly, always remember this important rule of thumb: Good code first, performance last.

A list can insert and remove anywhere, which is not what a FIFO structure is suppose to do, and a deque can add and remove from either end, which is also something a FIFO structure cannot do. It makes your intent clear to anybody else, and even yourself. The reason for this is simple: it is a FIFO structure. Since there are a myriad of answers, you might be confused, but to summarize:
