summaryrefslogtreecommitdiffhomepage
path: root/compat/time.hpp
blob: fbe7469a3bd464f74e82238709c9de3fbd8ff40f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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