#Unable to remove from std::list

1 messages · Page 1 of 1 (latest)

wheat iron
#
heightmapIsland::heightmapIsland(std::list<heightmapTile> &usedList)
{
    std::list<heightmapIsland> pendingIslands;

    heightmapTile firstTile = usedList.front();
    std::list<heightmapTile> firstTileList = std::list<heightmapTile>{ firstTile };
    std::list<heightmapTile> firstChain = firstTile.allConnected( firstTileList, std::pair<int, int>(0, 0));

    heightmapIsland firstIsland = heightmapIsland();
    firstIsland.tiles = firstChain;
    pendingIslands.emplace_back( firstIsland );

    for (heightmapTile usedTile : firstIsland.tiles)
    {
        usedList.remove(usedTile);
    }

    while (usedList.size() > 0)
    {
        for (heightmapIsland &island : pendingIslands)
        {
            for (heightmapTile tile : island.tiles)
            {

            }
        }
    }
}```

When I try writing code, and specifically adding the usedList.remove(usedTile) it tells me "binary '==': 'const _Ty' does not define this operator or a conversion to a type acceptable to the predefined operator" I did however overload the == operator for the heightmapTile class that would return true if two are the same, even if they're memory isn't. I'm trying to do it based on address/instance though.
cold plinthBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

slate glen
#

Show the full error message.

wheat iron
#

binary '==': 'const _Ty' does not define this operator or a conversion to a type acceptable to the predefined operator

slate glen
#

View in the Output window.

wheat iron
slate glen
wheat iron
#
bool operator==(heightmapTile A, heightmapTile B)
{
    return A.southLat() == B.southLat() &&
        A.northLat() == B.northLat() &&
        A.westLong() == B.westLong() &&
        A.eastLong() == B.eastLong();
}```
slate glen
#

Is this visible where you are using it?

wheat iron
#

I believe so.

wheat iron
#

Do I need to write another class just to do all this by now?

slate glen
deep grove
#

Try with this signature:
bool operator==(const heightmapTile & A, const heightmapTile & B)

or add
bool operator==(const heightmapTile & other) const
to your class heightmapTile

wheat iron
deep grove
#

Add const to function northLat southLat and so on.

rancid crescent
#

ah nvm, someone said that already, mb

wheat iron
#

I figured a work around. Sorry everyone

#

!solved