我尝试使用C ++中的STL创建类型为Job
的最小优先级队列。我有以下代码:
class Job
{
public:
int IOtime;
};
struct grThan
{
bool operator()(const Job& l, const Job& r) const
{
return l.IOtime > r.IOtime;
}
};
我正在声明队列std::priority_queue<Job, vector<Job>, grThan> IO;
我收到以下错误:
bool std::operator <(const std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem *)' : could not deduce template argument for 'const std::basic_string<_Elem,_Traits,_Alloc> &' from 'const Job'
答案 0 :(得分:0)
// stackoverflow_26691997.cpp (cX) 2015 adolfo.dimare@gmail.com
// http://stackoverflow.com/questions/26691997/
#include <queue>
#include <vector>
class Job {
public:
int IOtime;
};
struct grThan {
bool operator()(const Job& l, const Job& r) const {
return l.IOtime > r.IOtime;
}
};
int main() {
std::priority_queue<Job, std::vector<Job>, grThan> IO;
}