22#ifndef LELY_LIBC_CHRONO_HPP_
23#define LELY_LIBC_CHRONO_HPP_
33#if __cpp_lib_chrono >= 201907L
35using ::std::chrono::clock_cast;
39template <
class Dest,
class Source,
class Duration>
41inline typename ::std::enable_if<
42 ::std::is_same<Dest, Source>::value,
43 ::std::chrono::time_point<Dest, Duration>>::type
44clock_cast(const ::std::chrono::time_point<Source, Duration>& t) {
53template <
class Dest,
class Source,
class Duration>
55inline typename ::std::enable_if<
56 !::std::is_same<Dest, Source>::value,
57 ::std::chrono::time_point<Dest, Duration>>::type
58clock_cast(const ::std::chrono::time_point<Source, Duration>&
t) {
60 using time_point = ::std::chrono::time_point<Dest, Duration>;
61 auto d1 = Dest::now().time_since_epoch();
62 auto s = Source::now().time_since_epoch();
63 auto d2 = Dest::now().time_since_epoch();
64 return time_point{
t.time_since_epoch() + ((
d1 -
s) + (
d2 -
s)) / 2};
This header file is part of the Lely libraries; it contains the compiler feature definitions.