For the std::priority_queue I assumed that the first template parameter specified the type and the second should be a container of that type. Example:
priority_queue<int, vector<int>> someQueue;
However, the following code compiles and seems to run fine:
class SomeClass
{
};
int main()
{
priority_queue <SomeClass, vector<int>> pq;
int x = 9;
pq.push(x);
int t = pq.top();
cout << t << endl;
pq.pop();
return 0;
}
Is the above code invalid (i.e. giving UB)?
If it is valid - what is the first template parameter (i.e. someClass
) used for in the priority_queue.