Notitie
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen u aan te melden of de directory te wijzigen.
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen de mappen te wijzigen.
Een eigenschap die aangeeft hoe een van het time_point ene type klok naar het andere moet worden geconverteerd, terwijl het equivalente tijdstip behouden blijft.
Syntaxis
// C++20
1) template<class Dest, class Source> struct clock_time_conversion {};
2) template<class Clock> struct clock_time_conversion<Clock, Clock>;
3) template<> struct clock_time_conversion<system_clock, system_clock>;
4) template<> struct clock_time_conversion<utc_clock, utc_clock>;
5) template<> struct clock_time_conversion<system_clock, utc_clock>;
6) template<> struct clock_time_conversion<utc_clock, system_clock>;
7) template<class Clock> struct clock_time_conversion<Clock, system_clock>;
8) template<class Clock> struct clock_time_conversion<system_clock, Clock>;
9) template<class Clock> struct clock_time_conversion<Clock, utc_clock>;
10) template<class Clock> struct clock_time_conversion<utc_clock, Clock>;
Sjabloonparameters
Clock
Een kloktype om van/naar te converteren.
Dest
Het type klok dat moet worden geconverteerd naar.
Source
Het type klok waaruit moet worden geconverteerd.
De eigenschappen bieden de volgende conversies:
1) Een lege struct die alleen is gedefinieerd, zodat deze kan worden gespecialiseerd.
2-4) Identiteitsconversies. Retourneert dezelfde klok die u doorgeeft.
5-6) Converteren tussen sys_time en utc_time aanroepen utc_clock::to_sys of utc_clock::from_sys afhankelijk van de richting van de conversie.
7-8) Converteren tussen sys_time en de opgegeven klok, wanneer de opgegeven klok ondersteunt to_sys en from_sys, resulteert in een oproep naar Clock::to_sys of Clock::from_sys, afhankelijk van de richting van de conversie.
9-10) Converteren tussen utc_time en de opgegeven klok, wanneer de opgegeven klok ondersteunt from_utc en to_sys, resulteert in een oproep naar Clock::to_utc of Clock::from_utc, afhankelijk van de richting van de conversie.
Leden
| Naam | Beschrijving |
|---|---|
operator () |
Converteert een time_point van de ene klok naar de andere. |
Opmerkingen
Meestal gebruikt u deze eigenschap meestal niet rechtstreeks in uw code. Deze wordt gebruikt door de clock_cast conversiefunctie.
Behoeften
Rubriek:<chrono>
Namespace:std::chrono
compileroptie:/std:c++latest
operator()
Converteert een van het time_point ene kloktype naar het andere, terwijl het equivalente tijdstip behouden blijft.
Syntaxis
1)
template <class Duration>
time_point<Clock, Duration> operator()(const time_point<Clock, Duration>& t) const;
2)
template <class Duration>
sys_time<Duration> operator()(const sys_time<Duration> & t) const;
3)
template <class Duration>
utc_time<Duration> operator()(const utc_time<Duration>& t) const;
4)
template <class Duration>
sys_time<Duration> operator()(const utc_time<Duration>& t) const;
5)
template <class Duration>
utc_time<Duration> operator()(const sys_time<Duration>& t) const;
Parameterwaarden
t
De time_point die u wilt converteren.
Retourwaarde
1-3) Identiteitsconversies. Geen conversie. Retourneert t zonder wijzigingen.
4) Retourneert utc_clock::to_sys(t).
5) Retourneert utc_clock::from_sys(t).
Aftrekhandleidingen
De volgende aftrekhandleidingen worden verstrekt voor template <class Duration> operator():
1)
template <class Duration> auto operator()(const sys_time<Duration>& t) const
-> decltype(Clock::from_sys(t));
2)
template <class Duration> auto operator()(const time_point<SourceClock, Duration>& t) const
-> decltype(Clock::to_sys(t));
3)
template <class Duration> auto operator()(const utc_time<Duration>& t) const
-> decltype(Clock::from_utc(t));
4)
template <class Duration> auto operator()(const time_point<Clock, Duration>& t) const
-> decltype(Clock::to_utc(t));
1) Neemt alleen deel aan overbelastingsresolutie als Clock ondersteuning from_sys() en retourneert time_point<Clock, Duration>.
2) Neemt alleen deel aan overbelastingsresolutie als Clock ondersteuning to_sys() en retourneert sys_time<Duration>.
3) Neemt alleen deel aan overbelastingsresolutie als Clock ondersteuning from_utc() en retourneert time_point<Clock, Duration>.
4) Neemt alleen deel aan overbelastingsresolutie als Clock ondersteuning to_utc() en retourneert utc_time<Duration>.
Voorbeeld: clock_time_conversion
#include <iostream>
#include <chrono>
using namespace std::chrono;
int main()
{
auto sd = sys_days{ 2021y / July / 26 };
auto time = clock_time_conversion<utc_clock, system_clock>{}(sd);
std::cout << time << "\n";
return 0;
}
2021-07-26 00:00:00
Zie ook
<chrono>
clock_cast
headerbestanden