summaryrefslogtreecommitdiffhomepage
path: root/compat/time.hpp
diff options
context:
space:
mode:
authorStanisław Halik <sthalik@misaki.pl>2017-05-14 16:22:09 +0200
committerGitHub <noreply@github.com>2017-05-14 16:22:09 +0200
commit5c23666b58bb1dd4aea15c0d62a2f716d5be7f52 (patch)
treee6497e9b55c073be209ec673ef05e62bf57a2c8f /compat/time.hpp
parent4701dd3b0c8323a11cf7d5ad09c579a9864a41bd (diff)
parentc392181211b245e74292424500265323c960c1aa (diff)
Merge branch 'unstable' into unstable
Diffstat (limited to 'compat/time.hpp')
-rw-r--r--compat/time.hpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/compat/time.hpp b/compat/time.hpp
new file mode 100644
index 00000000..fbe7469a
--- /dev/null
+++ b/compat/time.hpp
@@ -0,0 +1,25 @@
+#pragma once
+
+#include <chrono>
+#include <type_traits>
+
+namespace time_units {
+
+template<typename repr, typename ratio>
+using duration = std::chrono::duration<repr, ratio>;
+
+template<typename t, typename u>
+static inline constexpr auto time_cast(const u& in)
+{
+ return std::chrono::duration_cast<t>(in);
+}
+
+using secs = duration<double, std::ratio<1, 1>>;
+using secs_ = duration<long long, std::ratio<1, 1>>;
+using ms = duration<double, std::milli>;
+using ms_ = duration<long long, std::milli>;
+using us = duration<double, std::micro>;
+using us_ = duration<long long, std::micro>;
+using ns = duration<long long, std::nano>;
+
+} // ns time_units