If you create a new queue, you can use the constructor:
std::vector<int> v = get_vector(); std::queue<long int, std::deque<long int>> q(std::deque<long int>(v.begin(), v.end()));
(You can change the base container to taste, although deque is probably the best.)
If the queue already exists, then there is no range-based algorithm, however you can easily write your own:
template <typename Iter, typename Q> push_range(Q & q, Iter begin, Iter end) { for ( ; begin != end; ++begin) q.push(*begin); }
Aside: if your algorithm requires such flexibility, you are probably best off using std::deque first. Container adapters ( queue and stack ) should only be used if you want to explicitly indicate "this is the behavior I want" (i.e. Push / pop).
source share