How to convert std::queue to std::vector
问题 I need to make use of a queue of doubles because of the good properties it has as an ordered container. I want to pass this queue to a class constructor that accepts vectors. If I do that directly I get the following error: candidate constructor not viable: no known conversion from 'std::queue' to 'std::vector &' for 2nd argument How to cast a queue to a vector? 回答1: The correct container to model both queue_like behaviour and vector-like behaviour is a std::deque . This has the advantages of