summaryrefslogtreecommitdiffhomepage
path: root/compat/time.hpp
diff options
context:
space:
mode:
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