Strict weak ordering with Coord structure

I'm trying to implement A* but am getting getting error C2678 because i am using std::set with my coord structure:

1
2
std::set<Coord> closedSet = {};
std::set<Coord> openSet = {};


I have no idea how to make my Coord structure satisfy strict weak ordering. Should i overload the < operator in the structure? If so how would i go about doing this, I have never dealt with this before.

1
2
3
4
5
6
7
8
9
10
11
12
13
struct Location {
	int g = 0; // Distance covered so far 
	int h = 0; // Estimate of distance to goal
	float f = 0; // Estimated cost of the complete path
	bool walkable = 0; // 0 = Walkable, 1 = Wall
};

// Structure 
struct Coord {
	int x;
	int y;
	Location location;
};

> getting error C2678
no idea what that is. ¿didn't your compiler provide a more descriptive message along with that code?

1
2
3
4
5
6
7
8
9
10
// Structure 
struct Coord {
	int x;
	int y;
	Location location;

	bool operator<(const Coord &b) const{
		//¿how do you compare coordinates?
	}
};
Topic archived. No new replies allowed.