summaryrefslogtreecommitdiffhomepage
path: root/compat/time.hpp
blob: 64cdc6f79faccc406c980f556005cbc8a90ebe26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#pragma once

#include <chrono>

namespace time_units {

template<typename repr, typename ratio = std::ratio<1>>
using duration = std::chrono::duration<repr, ratio>;

template<typename t, typename u>
static inline constexpr auto time_cast(u&& in)
{
    return std::chrono::duration_cast<t>(in);
}

using secs = duration<float>;
using ms = duration<float, std::milli>;
using us = duration<float, std::micro>;
using ns = duration<float, std::nano>;

} // ns time_units