| 1 |
#ifndef INCLUDED_CLOCKTIMECONV_ |
| 2 |
#define INCLUDED_CLOCKTIMECONV_ |
| 3 |
|
| 4 |
// previously included by demo.cc. Not needed anymore |
| 5 |
|
| 6 |
#include <type_traits> |
| 7 |
|
| 8 |
namespace std { |
| 9 |
namespace chrono { |
| 10 |
|
| 11 |
template <class DestClock, class SourceClock> |
| 12 |
struct clock_time_conversion {}; |
| 13 |
|
| 14 |
template <class ClockType> |
| 15 |
struct clock_time_conversion<ClockType, ClockType> |
| 16 |
{ |
| 17 |
template <class ChronoDuration> |
| 18 |
[[nodiscard]] time_point<ClockType, ChronoDuration> operator() |
| 19 |
(time_point<ClockType, ChronoDuration> const & timePoint) const |
| 20 |
noexcept(is_arithmetic<typename ChronoDuration::rep>::value) |
| 21 |
// strengthened |
| 22 |
{ |
| 23 |
std::cout << "clock_time_conversion 1\n"; |
| 24 |
return timePoint; |
| 25 |
} |
| 26 |
}; |
| 27 |
|
| 28 |
template <> |
| 29 |
struct clock_time_conversion<system_clock, system_clock> |
| 30 |
{ |
| 31 |
template <class ChronoDuration> |
| 32 |
[[nodiscard]] sys_time<ChronoDuration> operator()( |
| 33 |
sys_time<ChronoDuration> const &timePoint) const |
| 34 |
noexcept(is_arithmetic<typename ChronoDuration::rep>::value) |
| 35 |
// strengthened |
| 36 |
{ |
| 37 |
std::cout << "clock_time_conversion 2\n"; |
| 38 |
return timePoint; |
| 39 |
} |
| 40 |
}; |
| 41 |
|
| 42 |
// No utc_clock in chrono. |
| 43 |
// ======================= |
| 44 |
// |
| 45 |
//template <> |
| 46 |
//struct clock_time_conversion<utc_clock, utc_clock> { |
| 47 |
// template <class ChronoDuration> |
| 48 |
// [[nodiscard]] utc_time<ChronoDuration> operator()(const utc_time<ChronoDuration>& timePoint) const |
| 49 |
// noexcept(is_arithmetic_v<typename ChronoDuration::rep>) /* strengthened */ { |
| 50 |
// return timePoint; |
| 51 |
// } |
| 52 |
//}; |
| 53 |
// |
| 54 |
//// [time.clock.cast.sys.utc] |
| 55 |
// |
| 56 |
//template <> |
| 57 |
//struct clock_time_conversion<utc_clock, system_clock> { |
| 58 |
// template <class ChronoDuration> |
| 59 |
// [[nodiscard]] utc_time<common_type_t<ChronoDuration, seconds>> operator()(const sys_time<ChronoDuration>& _Sys_time) const { |
| 60 |
// return utc_clock::from_sys(_Sys_time); |
| 61 |
// } |
| 62 |
//}; |
| 63 |
// |
| 64 |
//template <> |
| 65 |
//struct clock_time_conversion<system_clock, utc_clock> { |
| 66 |
// template <class ChronoDuration> |
| 67 |
// [[nodiscard]] sys_time<common_type_t<ChronoDuration, seconds>> operator()(const utc_time<ChronoDuration>& _Utc_time) const { |
| 68 |
// return utc_clock::to_sys(_Utc_time); |
| 69 |
// } |
| 70 |
//}; |
| 71 |
|
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
#endif |