std::queue iteration

jackhab picture jackhab · Aug 11, 2009 · Viewed 144.6k times · Source

I need to iterate over std::queue. www.cplusplus.com says:

By default, if no container class is specified for a particular queue class, the standard container class template deque is used.

So can I somehow get to the queue's underlying deque and iterate over it?

Answer

CB Bailey picture CB Bailey · Aug 11, 2009

If you need to iterate over a queue then you need something more than a queue. The point of the standard container adapters is to provide a minimal interface. If you need to do iteration as well, why not just use a deque (or list) instead?