It seems that the cmp parameter in priority is different from that in sort() function. I do not know the reason for it.
Thanks very much if you can help me.
The type of cmp - the closure type of the lambda expression - is left to the implementation.
There is no other good way to specify its type.
> Why should I use minheap(cmp)
With C++20, where closure types without a capture have a defaulted default constructor, we can write: std::priority_queue < ListNode*, std::vector<ListNode*>, decltype(cmp) > minheap ;
Prior to C++20, a closure type is not default constructible, we need to create it via a lambda expression and pass it to the constructor (it is a copyable object).