[distance] fix compilation errors with darwin gcc 4.2.1 and msvc-12.0