そのため、構造体を作成して演算子TileSet
をオーバーライドし、優先キューに入れようとしています。const 参照で非 const メソッドを呼び出すことはできないと読みましたが、実際には問題はないはずです。メンバーを変更するのではなく、メンバーにアクセスしているだけです。<
TileSet
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;
}
};
エラーメッセージは私に教えてくれます:'const TileSet' as 'this' argument of 'bool TileSet::operator<(const TileSet&)' discards qualifiers [-fpermissive]
これはどういう意味ですか?変数を const に変更してもうまくいきませんでした。とにかく非 const にする必要があります。
私がやろうとするとエラーが発生します:
std::priority_queue<be::Object::TileSet> tileset_queue;