I feel dumb to ask this question, but I really want to know the reason before I seriously "type twice" in my future code.
For example, I construct an absolute max priority_queue from myVector (a vector defined before the code):
auto comp = []( int a, int b ) { return abs(a) < abs(b); };
priority_queue<int, vector<int>, decltype(comp)> pq(comp, myVector);
The comp lambda is required to fill in template (which I agree, because this priority_queue instance will has that order attribute in its life), and also required in constructor (which confuses me).
Why can not the constructor deduce the order based from the order information in template?
Aucun commentaire:
Enregistrer un commentaire