How can I preallocate a std::priority_queue
with a container of type std::vector
?
std::priority_queue
I don't have enough reputation to comment on Mike Seymour's post, but he ommited the third template argument of std::priority_queue
:
std::vector container;
container.reserve(1024);
std::priority_queue, std::less> pq(std::less(), std::move(container));
It is quite verbose for sure, but it does the work.