As per cppreference, std::priority_queue is defined as a template of three arguments, T, Container and Compare, out of which the last two have default values based on T:
class Container = std::vector<T>,
class Compare = std::less<typename Container::value_type>
Now let's say that I'm very happy with these defaults, and want to construct an std::priority_queue<int> object from an existing std::vector<int> one.
The closest I can have is
priority_queue(const Compare& compare, Container&& cont);
which move-constructs the underlying container using cont and then heapifies it by calling std::make_heap.
It's all great, but I would have to explicitly provide a Compare object, i.e.
std::vector<int> vec;
// filling vec with values
std::priority_queue<int> pq{std::less<int>(), std::move(vec)};
Why doesn't std::priority_queue have constructors like
priority_queue(const Container& cont);
priority_queue(Container&& cont);
It only seems reasonable, as it has a comparator-only constructor:
explicit priority_queue(const Compare& compare)
: priority_queue(compare, Container()) { }
Or am I missing some other way to do it?