With the idea from: declaring a priority_queue in c++ with a custom comparator ,
I tried to use lambda as comparator for the priority_queue, but when I tried to declare an array of it, error comes.
code:
class Klass{public:int raw_hash;int name;};
bool PriorByRaw(Klass a, Klass b){return a.raw_hash > b.raw_hash;}
auto prior = [](Klass a, Klass b){return PriorByRaw(a, b);};
//here comes the error before "[10]": expected a ';'
priority_queue<Klass, vector<Klass>, decltype(prior)> pq(prior)[10];
The question is how can I declared an array of priority_queue in this manner? Or is there any other solution? As one day I may need a priority que which use other functions as comparator (say "PriorByName"), overriding the less function for the "Klass" looks not good.
I've tried but didn't work:
priority_queue<Klass, vector<Klass>, decltype(prior)> pq(prior)[10];
priority_queue<Klass, vector<Klass>, decltype(prior)> (pq(prior))[10];