declaring a priority_queue in c++ with a custom comparator
Note – You may also want to check other answers, especially the one with decltype and lambda You should declare a class Compare and overload operator() for it like this: Or, if you for some reasons can’t make it as class, you could use std::function for it: