I want to have a priority queue with a custom order, but lazy, like me, I donβt want to define the implementation class of the comparator () class.
I would like something like this to compile:
std::priority_queue<int, std::vector<int>, boost::bind(some_function, _1, _2, obj1, obj2)> queue;
where some_function is a bool return function that takes four arguments, the first and second are the ints of the queue, and the last two are some of the objects needed to calculate the ordering (const references).
(error: "boost :: bind cannot be displayed in constant expression)
But this does not compile. Even simpler
std::priority_queue<int, std::vector<int>, &compare> queue;
will not compile, and the comparison will be a binary function that returns bool.
(error: type / value mismatch in argument 3 in the template parameter list for 'template class std :: priority_queue; expected type obtained by' compare)
Any suggestions?
source share