When creating a STL priority_queue, the third argument (the one that decides how to compare elements in the queue to decide which is largest)must be a class in which the function operator is defined. It would be much more convenient if a lambda expression could be supplied. Why is that not allowed? A lambda expression should be considered to be compile time constant if it is not capturing any variables, right?
struct compare{
bool operator()(int p, int q){return p > q;}
};
priority_queue< int, vector<int>, compare> intpq;
priority_queue< int, vector<int>,
[](int p, int q){return p > q;}
> intpq2;
The second definition, i.e. of intpq2, gives an error: template argument 3 is invalid. Is there a fundamental problem in accepting the second definition, or is it just that the designers of priority_queue chose not to allow it?