On this page
std::chrono::clock_time_conversion
Defined in header <chrono> |
||
|---|---|---|
|
(since C++20) |
std::chrono::clock_time_conversion is a trait that specifies how to convert a std::chrono::time_point of the Source clock to that of the Dest clock. It does so by providing a const-callable operator() that accepts an argument of type std::chrono::time_point<Source, Duration> and returns a std::chrono::time_point<Dest, OtherDuration> that represents an equivalent point in time. The duration of the returned time point is computed from the source duration in a manner that varies for each specialization. clock_time_conversion is normally only used indirectly, via std::chrono::clock_cast.
A program may specialize clock_time_conversion if at least one of the template parameters is a user-defined clock type.
The primary template is an empty struct. The standard defines the following specializations:
|
(1) | (since C++20) |
|
(2) | (since C++20) |
|
(3) | (since C++20) |
|
(4) | (since C++20) |
|
(5) | (since C++20) |
|
(6) | (since C++20) |
|
(7) | (since C++20) |
|
(8) | (since C++20) |
|
(9) | (since C++20) |
operator() returns a copy of the argument.
std::chrono::sys_time and std::chrono::utc_time: operator() calls std::chrono::utc_clock::to_sys and std::chrono::utc_clock::from_sys, respectively.
std::chrono::sys_time when Clock supports from_sys and to_sys: operator() calls Clock::to_sys and Clock::from_sys, respectively.
std::chrono::utc_time when Clock supports from_utc and to_utc: operator() calls Clock::to_utc and Clock::from_utc, respectively.
Member functions
Each specialization has an implicitly-declared default constructor, copy constructor, move constructor, copy assignment operator, move assignment operator, and destructor.
std::chrono::clock_time_conversion::operator()
|
(1) | (member of specialization (1)) |
|
(2) | (member of specialization (2)) |
|
(3) | (member of specialization (3)) |
|
(4) | (member of specialization (4)) |
|
(5) | (member of specialization (5)) |
|
(6) | (member of specialization (6)) |
|
(7) | (member of specialization (7)) |
|
(8) | (member of specialization (8)) |
|
(9) | (member of specialization (9)) |
Converts the argument std::chrono::time_point to the destination clock.
t unchanged.
std::chrono::utc_clock::to_sys(t).
std::chrono::utc_clock::from_sys(t).
Clock::from_sys(t). This overload participates in overload resolution only if the expression Clock::from_sys(t) is well-formed. The program is ill-formed if Clock::from_sys(t) does not return std::chrono::time_point<Clock, Duration> where Duration is some valid specialization of std::chrono::duration.
Clock::to_sys(t). This overload participates in overload resolution only if the expression Clock::to_sys(t) is well-formed. The program is ill-formed if Clock::to_sys(t) does not return std::chrono::sys_time<Duration> where Duration is some valid specialization of std::chrono::duration.
Clock::from_utc(t). This overload participates in overload resolution only if the expression Clock::from_utc(t) is well-formed. The program is ill-formed if Clock::from_utc(t) does not return std::chrono::time_point<Clock, Duration> where Duration is some valid specialization of std::chrono::duration.
Clock::to_utc(t). This overload participates in overload resolution only if the expression Clock::to_utc(t) is well-formed. The program is ill-formed if Clock::to_utc(t) does not return std::chrono::utc_time<Duration> where Duration is some valid specialization of std::chrono::duration.
Parameters
| t | - | time point to convert |
Return value
The result of the conversion as described above:
t.
Clock::from_sys(t).
Clock::to_sys(t).
Clock::from_utc(t).
Clock::to_utc(t).
See also
|
(C++20)
|
convert time points of one clock to another (function template) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/chrono/clock_time_conversion