SyntaxFix
Write A Post
Hire A Developer
Questions
One indirect solution can be to use std::deque instead. It supports all operations of queue and you can iterate over it just by using for(auto& x:qu). It's much more efficient than using a temporary copy of queue for iteration.
for(auto& x:qu)