[core] Polyfill std::chrono::abs

This commit is contained in:
John Firebaugh
2016-01-21 13:03:03 -08:00
parent cef5c331fe
commit fa894d7cbc
2 changed files with 9 additions and 3 deletions

View File

@@ -53,6 +53,14 @@ std::string iso8601(SystemTimePoint);
SystemTimePoint parseTimePoint(const char *);
// C++17 polyfill
template <class Rep, class Period, class = std::enable_if_t<
std::chrono::duration<Rep, Period>::min() < std::chrono::duration<Rep, Period>::zero()>>
constexpr std::chrono::duration<Rep, Period> abs(std::chrono::duration<Rep, Period> d)
{
return d >= d.zero() ? d : -d;
}
} // namespace util
} // namespace mbgl