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?
std::queue
is a container adaptor, and you can specify the container used (it defaults to use adeque
). If you need functionality beyond that in the adaptor then just use adeque
or another container directly.In short: No.
There is a hack, use vector as underlaid container, so
queue::front
will return valid reference, convert it to pointer an iterate until <=queue::back