std::chrono:: clock_time_conversion
|
定义于头文件
<chrono>
|
||
|
template
<
class
Dest,
class
Source
>
struct clock_time_conversion { } ; |
(C++20 起) | |
std::chrono::clock_time_conversion
是一个特性类,用于指定如何将
Source
时钟的
std::chrono::time_point
转换为
Dest
时钟的对应时间点。它通过提供一个常量调用运算符
operator()
来实现此功能,该运算符接受
std::
chrono
::
time_point
<
Source, Duration
>
类型的参数,并返回表示同一时间点的
std::
chrono
::
time_point
<
Dest, OtherDuration
>
。返回时间点的时长会根据不同特化以不同方式从源时长计算得出。
clock_time_conversion
通常仅通过
std::chrono::clock_cast
间接使用。
程序可以在至少一个模板参数为用户定义时钟类型时特化
clock_time_conversion
。
主模板是一个空结构体。标准定义了以下特化:
|
template
<
class
Clock
>
struct clock_time_conversion < Clock, Clock > ; |
(1) | (自 C++20 起) |
|
template
<>
struct clock_time_conversion < std:: chrono :: system_clock , std:: chrono :: system_clock > ; |
(2) | (自 C++20 起) |
|
template
<>
struct clock_time_conversion < std:: chrono :: utc_clock , std:: chrono :: utc_clock > ; |
(3) | (自 C++20 起) |
|
template
<>
struct clock_time_conversion < std:: chrono :: system_clock , std:: chrono :: utc_clock > ; |
(4) | (自 C++20 起) |
|
template
<>
struct clock_time_conversion < std:: chrono :: utc_clock , std:: chrono :: system_clock > ; |
(5) | (自 C++20 起) |
|
template
<
class
Clock
>
struct clock_time_conversion < Clock, std:: chrono :: system_clock > ; |
(6) | (自 C++20 起) |
|
template
<
class
Clock
>
struct clock_time_conversion < std:: chrono :: system_clock , Clock > ; |
(7) | (自 C++20 起) |
|
template
<
class
Clock
>
struct clock_time_conversion < Clock, std:: chrono :: utc_clock > ; |
(8) | (自 C++20 起) |
|
template
<
class
Clock
>
struct clock_time_conversion < std:: chrono :: utc_clock , Clock > ; |
(9) | (自 C++20 起) |
operator()
返回参数的副本。
operator()
分别调用
std::chrono::utc_clock::to_sys
和
std::chrono::utc_clock::from_sys
。
Clock
支持
from_sys
和
to_sys
时,与
std::chrono::sys_time
的相互转换:
operator()
分别调用
Clock
::
to_sys
和
Clock
::
from_sys
。
Clock
支持
from_utc
和
to_utc
时,与
std::chrono::utc_time
之间的相互转换:
operator()
分别调用
Clock
::
to_utc
和
Clock
::
from_utc
。
目录 |
成员函数
每个特化都有一个隐式声明的默认构造函数、复制构造函数、移动构造函数、复制赋值运算符、移动赋值运算符和析构函数。
std::chrono::clock_time_conversion:: operator()
|
template
<
class
Duration
>
std::
chrono
::
time_point
<
Clock, Duration
>
|
(1) | (特化成员 (1) ) |
|
template
<
class
Duration
>
std::
chrono
::
sys_time
<
Duration
>
|
(2) | (特化成员 (2) ) |
|
template
<
class
Duration
>
std::
chrono
::
utc_time
<
Duration
>
|
(3) | (特化成员 (3) ) |
|
template
<
class
Duration
>
std::
chrono
::
sys_time
<
Duration
>
|
(4) | (特化成员 (4) ) |
|
template
<
class
Duration
>
std::
chrono
::
utc_time
<
Duration
>
|
(5) | (特化成员 (5) ) |
|
template
<
class
Duration
>
auto
operator
(
)
(
const
std::
chrono
::
sys_time
<
Duration
>
&
t
)
const
|
(6) | (特化成员 (6) ) |
|
template
<
class
Duration
>
auto
operator
(
)
(
const
std::
chrono
::
time_point
<
SourceClock, Duration
>
&
t
)
const
|
(7) | (特化成员 (7) ) |
|
template
<
class
Duration
>
auto
operator
(
)
(
const
std::
chrono
::
utc_time
<
Duration
>
&
t
)
const
|
(8) | (特化成员 (8) ) |
|
template
<
class
Duration
>
auto
operator
(
)
(
const
std::
chrono
::
time_point
<
Clock, Duration
>
&
t
)
const
|
(9) | (特化成员 (9) ) |
将参数 std::chrono::time_point 转换为目标时钟。
t
。
参见
|
(C++20)
|
将一个时钟的时间点转换为另一个时钟
(函数模板) |