File: clocktypes.f

package info (click to toggle)
bobcat 6.11.00-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,292 kB
  • sloc: cpp: 21,370; fortran: 6,507; makefile: 2,787; sh: 724; perl: 401; ansic: 26
file content (59 lines) | stat: -rw-r--r-- 1,252 bytes parent folder | download | duplicates (2)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
template <typename Dest, typename Src>
inline auto toClock(Src const &src)
{
    return std::chrono::clock_cast<typename Dest::ChronoClock>(
                                                            src.timePoint());
}

template <typename Dest, typename Src>
inline Dest toDuration(Src const &src)
{
    return std::chrono::duration_cast<Dest>(src);
}

template <typename Dest, typename Src>
inline double toDouble(Src const &src)
{
    return static_cast<double>(src.count()) * 
                            Dest::period::den * Src::period::num /
                            (Dest::period::num * Src::period::den);
}

// static
inline ClockTypes::Period ClockTypes::period()
{
    return Duration::period{};
}

// static
inline ClockTypes::NumType ClockTypes::den()
{
    return Period::den;
}

// static
inline ClockTypes::NumType ClockTypes::num()
{
    return Period::num;
}

// static
inline ClockTypes::Duration ClockTypes::zero()
{
    return Duration::zero();
}

// static 
template <typename TimePoint>
inline ClockTypes::Duration ClockTypes::elapsed(TimePoint const &tp)
{
    return tp.time_since_epoch();
}

// static 
template <typename TimePoint>
inline size_t ClockTypes::count(TimePoint const &tp)
{
    return elapsed(tp).count();
}