summaryrefslogtreecommitdiff
path: root/include/mbgl/util/chrono.hpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-01-21 13:03:03 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-01-22 18:41:54 -0800
commitfa894d7cbc7e27a64fa7e466fa56e718079da24c (patch)
tree8ab4c23e1ed7becacb72c20d4809e4ad6cc39589 /include/mbgl/util/chrono.hpp
parentcef5c331fe6ab827e71aed1e4e0387983083c88e (diff)
downloadqtlocation-mapboxgl-fa894d7cbc7e27a64fa7e466fa56e718079da24c.tar.gz
[core] Polyfill std::chrono::abs
Diffstat (limited to 'include/mbgl/util/chrono.hpp')
-rw-r--r--include/mbgl/util/chrono.hpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/mbgl/util/chrono.hpp b/include/mbgl/util/chrono.hpp
index dd228df977..219b827536 100644
--- a/include/mbgl/util/chrono.hpp
+++ b/include/mbgl/util/chrono.hpp
@@ -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