jackhab jackhab - 4 months ago 32
C++ Question

std::queue iteration

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

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?