fixup compilation for OS X

Apparently OS X does not provide an int std::abs(int) at all, or
we aren't including it properly or someting. I work around this.
This commit is contained in:
Chris Beck 2014-10-27 03:04:21 -04:00
parent b05773c409
commit 7ce9199e47

View file

@ -350,10 +350,13 @@ inline bool tiles_adjacent(const map_location& a, const map_location& b)
*/
}
// OS X appears not to provide std::abs with overload for int
inline int _abs(int x) {
return (x < 0) ? -x : x;
}
inline size_t distance_between(const map_location& a, const map_location& b)
{
int (*_abs)( int ) = & std::abs; // Needed to resolve ambiguity for OS X compilation
const size_t hdistance = _abs(a.x - b.x);
const size_t vpenalty = ( (((a.x & 1)==0) && ((b.x & 1)==1) && (a.y < b.y))