resolve ambiguities in referring to std::abs, in map_location.hpp
Ancestral reported compilation errors with clang on OS X, basically similar to what is reported here: https://github.com/Project-OSRM/osrm-backend/issues/1000 I fix it by replacing calls to std::abs, with calls to _abs, a function pointer I define to be & _abs, so that I can control exactly which overload is selected and thus resolve the ambiguity.
This commit is contained in:
parent
afaca721a3
commit
b05773c409
1 changed files with 4 additions and 2 deletions
|
@ -352,7 +352,9 @@ inline bool tiles_adjacent(const map_location& a, const map_location& b)
|
|||
|
||||
inline size_t distance_between(const map_location& a, const map_location& b)
|
||||
{
|
||||
const size_t hdistance = std::abs(a.x - b.x);
|
||||
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))
|
||||
|| (((b.x & 1)==0) && ((a.x & 1)==1) && (b.y < a.y)) ) ? 1 : 0;
|
||||
|
@ -367,7 +369,7 @@ inline size_t distance_between(const map_location& a, const map_location& b)
|
|||
// = maximum(hdistance, vdistance+hdistance-hdistance/2-hdistance%2)
|
||||
// = maximum(hdistance,abs(a.y-b.y)+vpenalty+hdistance/2)
|
||||
|
||||
return std::max<int>(hdistance, std::abs(a.y - b.y) + vpenalty + hdistance/2);
|
||||
return std::max<int>(hdistance, _abs(a.y - b.y) + vpenalty + hdistance/2);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue