std::priority_queue<int, std::vector<int>, decltype(cmp)> q3(cmp);
This is specifying what kind of priority queue is to be created, and the name of it, and the input parameter to the constructor.
To specify what kind of priority queue is to be created, three types must be specified:
std::priority_queue<int, std::vector<int>, decltype(cmp)> q3(cmp);
In this case:
The first type is an int.
The second type is a vector of int.
The third type is whatever type cmp happens to be. That's what
decltype(cmp)
does; it effectively means "the type of cmp".
std::priority_queue<int, std::vector<int>, decltype(cmp)> q3(cmp);
The priority queue in this case is named
q3.
std::priority_queue<int, std::vector<int>, decltype(cmp)> q3(cmp);
The constructor of the priority queue is being given one parameter:
cmp
.
In this case, cmp is a lambda function being passed to the priority queue; the priority queue will use this lambda function to decide the order of the items in the queue. It is called a lambda function. The requirement on using it here is that it must satisfy the conditions of
http://en.cppreference.com/w/cpp/concept/Compare ; whatever it is
must meet those conditions to be used. cmp doesn't
have to be a lambda function; it could be anything that meets those conditions.