I have a vector of min priority queues, each one created with different instance of custom comparator class. Queues are supposed to be limited in size, and in case the queue is full, only element with higher priority than top of the queue can be inserted and kick out the element on top. So before inserting into full queue I want to compare new element against the top of the queue using the queues’ own comparator to avoid the insertion/deletion cost. Is that possible to do without recreating the comparator?
Edit:
@Kerrek’s hack is really cool but the comparators do have to be created by constructor with parameter, I should’ve mentioned that. So I went with @Spundun answer, also I used access to underlying container for faster printing.
the comparator is a protected member(named comp, +1 Nate). So if you derive your own priority queue class from the stl class, and implement the functionality you described as a function (say insert_only_if_important() ) then you can access the comparator from within that function.