So, I'm trying to make a struct TileSet
and override the <
operator, and then put TileSet
's in a priority queue. I've read that I can't call non-const methods on a const reference, but there shouldn't really be a problem, I'm just accessing members, not changing them:
struct TileSet
{
// ... other struct stuff, the only stuff that matters
TileSet(const TileSet& copy)
{
this->gid = copy.gid;
this->spacing = copy.spacing;
this->width = copy.width;
this->height = copy.height;
this->texture = copy.texture;
}
bool operator<(const TileSet &b)
{
return this->gid < b.gid;
}
};
The error message tells me: passing 'const TileSet' as 'this' argument of 'bool TileSet::operator<(const TileSet&)' discards qualifiers [-fpermissive]
what does this mean? Changing the variables to const did not work, and I need them to be non-const anyways.
The error occurs when I try to do:
std::priority_queue<be::Object::TileSet> tileset_queue;