I am attempting to print a STL priority_queue in C++, but I am having issues printing all elements of the queue.
priority_queue<Job, vector<Job>, greater<Job>> q = pq;
for(int i = 0; i <= q.size(); i++) {
cout << q.top() << "\n";
q.pop();
}
However, using this code when there is one or two elements in the list it is fine, but as soon as I enter three or more elements it cuts off the last item to be printed. I'm not really sure why this is happening but it's been confusing me for a little while.