std::map errors
Since whole error cant really fit into one post (20000+ characters), I used pastebin:
http://pastebin.com/JW7AAaCx
I think this code causes it:
I got
std::map<Coord, Object*>
Where Coord is:
1 2 3 4 5 6 7
|
struct Coord
{
Coord(int x, int y) : x(x), y(y)
{}
int x;
int y;
};
|
Object is just abstract class from which everything derives from:
1 2 3 4
|
struct Object
{
virtual void Draw(sf::RenderWindow& Window) = 0;
};
|
This is example of I add elements into that std::map :
Maps[Path].Objects[Coord(x, y)] = new Map::Portal(PathToNewMap, nx, ny);
And I access specific Object in map like this:
1 2 3 4
|
for(auto itr = Maps[PathToMap].Objects.begin(); itr != Maps[PathToMap].Objects.end(); ++itr)
{
itr->second->Draw(Window);
}
|
Last edited on
since map sorts the entries you need to implement the
operator<()
like so:
1 2 3 4 5 6 7 8 9 10 11
|
struct Coord
{
Coord(int x, int y) : x(x), y(y)
{}
int x;
int y;
bool operator<(const Coord &coord) const
{
return ((x < coord.x) || (y < coord.y));
}
};
|
Thanks!
Topic archived. No new replies allowed.