This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of NAD status.
Section: 26.6.5 [priority.queue] Status: NAD Submitter: Matt Austern Opened: 2015-10-27 Last modified: 2017-02-03
View all other issues in [priority.queue].
View all issues with NAD status.
Suppose we want to remove and process the topmost element of a priority_queue<T>. For a copyable type we might write
auto tmp = q.top(); q.pop();
but of course that doesn't work if T is move-only. Nothing of that sort can work, since moving out of top() would make the subsequent call to pop() fail.Currently, pop() is defined to perform
pop_heap(c.begin(), c.end(), comp); c.pop_back();
so the removed value continues to exist between the first and second lines but there isn't any access to it. The sort of primitive that would allow consuming and removing the topmost element would be some variation on this, e.g.
pop_heap(c.begin(), c.end(), comp); auto tmp = move(c.back()); c.pop_back(); return tmp;
[2016-02, Issues Telecon]
This should be addressed by a paper addressed to LEWG.