const_cast: A Necessary Evil
Summary
This post explains why const_cast is sometimes necessary in C++, using the std::priority_queue where top returns a const reference and moving the object out requires casting away const. It provides a minimal code pattern to exfiltrate a move-only object, then restore the container's invariants, and notes that this is a known quirk for certain standard library containers.