title: How to retrieve and modify element from priority queue
body: <p>I am trying to call the following: </p>
  
  <pre><code>Event&amp; event = events.top();  //This line throws an error because event isn't const
  events.pop();
  event.process();  //But event can't be const because this function is intentionally not const
  </code></pre>
  
  <p>Where <code>events</code> is a priority queue, and <code>process</code> will modify the object.  However, <code>events.top()</code> returns a <code>const &amp;</code>.  I believe that the copy constructor doesn't exist because <code>Event</code> is a abstract class, containing pure virtual functions.</p>
  
  <p>Hence, I only see two options here:</p>
  
  <ol>
  <li>Remove the pure virtual functions</li>
  <li>Use some magic casting to remove the <code>const</code>.</li>
  </ol>
  
  <p>I don't really like either of those options.  <strong>Is there a better way to pop, and then modify, the top abstract element from this priority queue?</strong> </p>
  
  <p>As a side note, <code>process()</code> doesn't change anything contained in the base Event class, only its subclasses need that functionality.</p>