-3

I am trying to convert a min-heap priority queue to return as a vector of ints. Is this type conversion is possible in C++;

Mr Null Pointer
  • 101
  • 1
  • 2
  • 8

1 Answers1

2

The C++ std::priority_queue uses a container for storage https://en.cppreference.com/w/cpp/container/priority_queue

By default it is class Container = std::vector<T>

Is this what you want to get access to ? If so, though luck:

C, the underlying container (protected member object)

It is not exposed. You could derive from priority_queue and expose it, if needed. But you post is thin as to what you are actually trying to do.

Keep in mind that:

  • The container doesn't store sorted elements. It is a heap, so only the first element will be correct. It might have little actual use.

This answer discusses accessing the Container: Is there a way to access the underlying container of STL container adaptors?

Jeffrey
  • 11,063
  • 1
  • 21
  • 42