I am simulating CPU scheduling algorithms for a class. I have a struct called job that contains the basic info for each job, and I'm trying to order a priority queue of these jobs in order from smallest number of cycles needed to largest number of cycles needed. This is currently my custom comparator to do that:
class CompareJobTime {
public:
bool operator()(job job1, job job2) {
if (job1.cycles < job2.cycles) {
return false;
}
else
return true;
}
};
and this is how I'm using it in the priority queue declaration:
priority_queue<job, vector<job>, CompareJobTime> jobTPQ;
This is the error it keeps getting: "Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\include\xutility Line:1096
Expression: invalid comparator"
Any help would be greatly appreciated, as I really don't have a clue where to go from here when it comes to debugging. Thanks!
I've tried changing up the definition in a couple ways, but I'm not sure what's wrong with it. I have also tried using decltype instead of a comparator class, but I couldn't get that to work since I was writing the comparator function as a member of the class this is all being written in.