I have a priority queue of pointers to a struct city. I modify the objects pointed by these pointers outside the priority queue, and want to tell the priority q
This is a bit hackish, but nothing illegal about it, and it gets the job done.
std::make_heap(const_cast(&cities.top()),
const_cast(&cities.top()) + cities.size(),
Compare());
Update:
Do not use this hack if:
vector.Compare functor has behavior that would cause your external copy to order differently than the copy of Compare stored inside the priority_queue.You can always write your own container adaptor which wraps the heap algorithms. priority_queue is nothing but a simple wrapper around make/push/pop_heap.