Created a boost::priority_queue with my comparison operation defined. Here is how my priority_queue looks,
boost::heap::priority_queue<myObject*, boost::heap::compare<myObjectPtrCompare> > max_heap;
My comparison is defined as,
struct myObjectPtrCompare
{
bool operator()(const myObject* lhs, const myObject* rhs) const
{
return (lhs->getTime() < rhs->getTime());
}
};
I have used it as,
myObject* obj1 = static_cast<myObject*>(base1);
'base1' is an object of class 'myBase'(base class of myObject)
myObject and getTime() within it used for comparision are defined as,
class myObject : public myBase {
Time getTime() const { return time; }
.
.
.
...
}
Compiling this gives me this error,
c:\Projects\pq_test.cpp(27): error C2662: 'void boost::heap::priority_queue<myObject*,boost::heap::compare<myObjectPtrCompare>,boost::parameter::void_,boost::parameter::void_,boost::parameter::void_>::push(myObject *const &)' : cannot convert 'this' pointer from 'const boost::heap::priority_queue<myObject *,boost::heap::compare<myObjectPtrCompare>,boost::parameter::void_,boost::parameter::void_,boost::parameter::void_>' to 'boost::heap::priority_queue<myObject *,boost::heap::compare<myObjectPtrCompare>,boost::parameter::void_,boost::parameter::void_,boost::parameter::void_> &'
1> Conversion loses qualifiers
Using Visual Studio 2013 C++. I understand that I am doing something wrong with const correctness, but I am not able to figure out what is wrong. Any help is appreciated.
TIA!