Section: 24.6.7 [priority.queue] Status: NAD Submitter: Matt Austern Opened: 2015-10-27 Last modified: 2016-02-07 20:24:45 UTC
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.