1 post tagged #move-semantics.
#move-semantics
priority_queue::top() returns a const reference, so a move-only element cannot be taken out of the queue at all: the copy constructor is selected and the code does not compile. The accepted workaround is a const_cast immediately followed by pop(), which is safe for one specific reason worth understanding before you write it.
// We use Google Analytics to understand which posts get traction and how the wro.cpp community grows. Anonymised, no ads, and you can decline -- the site works either way.