std::chrono::clock_time_conversion
提供: cppreference.com
<tbody>
</tbody>
| ヘッダ <chrono> で定義
|
||
template<class Dest, class Source> struct clock_time_conversion { }; |
(C++20以上) | |
std::chrono::clock_time_conversion は時計 Source の std::chrono::time_point を時計 Dest の std::chrono::time_point に変換する方法を規定する特性クラスです。 std::chrono::time_point<Source, Duration> 型の引数を取り、それと同等な時点を表す std::chrono::time_point<Dest, OtherDuration> を返す const-callable な operator() を提供することによって、それを行います。 元の duration から、返される time_point の duration を計算する方法は、各々の特殊化によって様々です。 clock_time_conversion は通常 std::chrono::clock_cast によって間接的にのみ使用されます。
テンプレート引数の少なくとも1つがユーザ定義時計型の場合、プログラムは clock_time_conversion を特殊化しても構いません。
プライマリテンプレートは空の構造体です。 標準は以下の特殊化を定義します。
<tbody> </tbody> 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以上) |
1-3) 恒等変換。
operator() は引数のコピーを返します。4-5) std::chrono::sys_time と std::chrono::utc_time の間で変換します。
operator() はそれぞれ std::chrono::utc_clock::to_sys および std::chrono::utc_clock::from_sys を呼びます。6-7)
Clock が from_sys および to_sys をサポートしているとき、 std::chrono::sys_time との間で変換します。 operator() はそれぞれ Clock::to_sys および Clock::from_sys を呼びます。8-9)
Clock が from_utc および to_utc をサポートしているとき、 std::chrono::utc_time との間で変換します。 operator() はそれぞれ Clock::to_utc および Clock::from_utc を呼びます。メンバ関数
各々の特殊化は暗黙に宣言されたデフォルトコンストラクタ、コピーコンストラクタ、ムーブコンストラクタ、コピー代入演算子、ムーブ代入演算子およびデストラクタを持ちます。
std::chrono::clock_time_conversion::operator()
<tbody> </tbody> template <class Duration> std::chrono::time_point<Clock, Duration> operator()(const std::chrono::time_point<Clock, Duration>& t) const; |
(1) | (特殊化 (1) のメンバ) |
template <class Duration> std::chrono::sys_time<Duration> operator()(const std::chrono::sys_time<Duration> & t) const; |
(2) | (特殊化 (2) のメンバ) |
template <class Duration> std::chrono::utc_time<Duration> operator()(const std::chrono::utc_time<Duration>& t) const; |
(3) | (特殊化 (3) のメンバ) |
template <class Duration> std::chrono::sys_time<Duration> operator()(const std::chrono::utc_time<Duration>& t) const; |
(4) | (特殊化 (4) のメンバ) |
template <class Duration> std::chrono::utc_time<Duration> operator()(const std::chrono::sys_time<Duration>& t) const; |
(5) | (特殊化 (5) のメンバ) |
template <class Duration> auto operator()(const std::chrono::sys_time<Duration>& t) const -> decltype(Clock::from_sys(t)); |
(6) | (特殊化 (6) のメンバ) |
template <class Duration> auto operator()(const std::chrono::time_point<SourceClock, Duration>& t) const -> decltype(Clock::to_sys(t)); |
(7) | (特殊化 (7) のメンバ) |
template <class Duration> auto operator()(const std::chrono::utc_time<Duration>& t) const -> decltype(Clock::from_utc(t)); |
(8) | (特殊化 (8) のメンバ) |
template <class Duration> auto operator()(const std::chrono::time_point<Clock, Duration>& t) const -> decltype(Clock::to_utc(t)); |
(9) | (特殊化 (9) のメンバ) |
引数 std::chrono::time_point を目的の時計に変換します。
1-3) 恒等変換。
t を変更せずに返します。4)
std::chrono::utc_clock::to_sys(t) を返します。5)
std::chrono::utc_clock::from_sys(t) を返します。6)
Clock::from_sys(t) を返します。 このオーバーロードは、式 Clock::from_sys(t) が well-formed である場合にのみ、オーバーロード解決に参加します。 Clock::from_sys(t) が std::chrono::time_point<Clock, Duration> (ただし Duration は何らかの有効な std::chrono::duration の特殊化) を返さない場合、プログラムは ill-formed です。7)
Clock::to_sys(t) を返します。 このオーバーロードは、式 Clock::to_sys(t) が well-formed である場合にのみ、オーバーロード解決に参加します。 Clock::to_sys(t) が std::chrono::sys_time<Duration> (ただし Duration は何らかの有効な std::chrono::duration の特殊化) を返さない場合、プログラムは ill-formed です。8)
Clock::from_utc(t) を返します。 このオーバーロードは、式 Clock::from_utc(t) が well-formed である場合にのみ、オーバーロード解決に参加します。 Clock::from_utc(t) が std::chrono::time_point<Clock, Duration> (ただし Duration は何らかの有効な std::chrono::duration の特殊化) を返さない場合、プログラムは ill-formed です。9)
Clock::to_utc(t) を返します。 このオーバーロードは、式 Clock::to_utc(t) が well-formed である場合にのみ、オーバーロード解決に参加します。 Clock::to_utc(t) が std::chrono::utc_time<Duration> (ただし Duration は何らかの有効な std::chrono::duration の特殊化) を返さない場合、プログラムは ill-formed です。引数
| t | - | 変換する time_point |
戻り値
上で説明した通りの変換の結果。
1-3)
t。4)
std::chrono::utc_clock::to_sys(t)。5)
std::chrono::utc_clock::from_sys(t)。6)
Clock::from_sys(t)。7)
Clock::to_sys(t)。8)
Clock::from_utc(t)。9)
Clock::to_utc(t)。
関連項目
(C++20) |
ある時計の時点を別の時計に変換します (関数テンプレート) |