Documentation states std::priority_queue::top
returns a constant reference to the top element in the priority_queue, but when printing the top element, the unary dereference operator is not used.
// priority_queue::top
#include <iostream> // std::cout
#include <queue> // std::priority_queue
int main ()
{
std::priority_queue<int> mypq;
mypq.push(10);
mypq.push(20);
mypq.push(15);
std::cout << "mypq.top() is now " << mypq.top() << '\n';
return 0;
}
Is top()
being implicitly dereferenced or is the returned value a copy?