From 6ad7beb64869e9248e597c386d0f044d9830b4cb Mon Sep 17 00:00:00 2001 From: Martin Read Date: Tue, 1 Oct 2013 22:21:16 +0100 Subject: [PATCH] Added mysign() specializations for Coord and Offset --- coord.hh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/coord.hh b/coord.hh index c0124d0..f3a06e8 100644 --- a/coord.hh +++ b/coord.hh @@ -52,7 +52,7 @@ struct Coord int y; int x; Offset delta(const Coord& right) const { Offset d = { y - right.y, x - right.x }; return d; } - Coord operator +(const Offset& right) const { Coord c = { y + right.y, x - right.x}; return c; } + Coord operator +(const Offset& right) const { Coord c = { y + right.y, x + right.x}; return c; } Coord operator -(const Offset& right) const { Coord c = { y - right.y, x - right.x}; return c; } const Coord& operator +=(const Offset& right) { y += right.y; x += right.x; return *this;} const Coord& operator -=(const Offset& right) { y -= right.y; x -= right.x; return *this;} @@ -63,6 +63,8 @@ struct Coord extern const Coord Nowhere; extern const Offset North, Northeast, East, Southeast, South, Southwest, West, Northwest, Stationary; +template<> inline Coord mysign(Coord val) { Coord c = { mysign(val.y), mysign(val.x) }; return c; } +template<> inline Offset mysign(Offset val) { Offset o = { mysign(val.y), mysign(val.x) }; return o; } #endif /* coord.hh */ -- 2.11.0