std::chrono::duration::duration
Da cppreference.com.
![]() |
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
constexpr duration() = default; |
(1) | |
duration(const duration&) = default; |
(2) | |
template <class Rep2> constexpr explicit duration(const Rep2& r); |
(3) | |
template <class Rep2, class Period2> constexpr duration(const duration<Rep2, Period2>& d); |
(4) | |
Costruisce un nuovo
duration
da una delle varie fonti di dati opzionali.Original:
Constructs a new
duration
from one of several optional data sources.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
1)
Il costruttore di default è default.
Original:
The default constructor is defaulted.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
2)
Il costruttore di copia viene preimpostata (fa una copia bit per bit del conteggio).
Original:
The copy constructor is defaulted (makes a bitwise copy of the tick count).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
3)
Costruisce una durata con le zecche
r
. Si noti che questo costruttore partecipa solo in risoluzione dell'overload se Rep2
(il tipo di argomento) è convertibile in modo implicito rep
(il tipo di zecche questa durata) eOriginal:
Constructs a duration with
r
ticks. Note that this constructor only participates in overload resolution if Rep2
(the argument type) is implicitly convertible to rep
(the type of this duration's ticks) andThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
- std::chrono::treat_as_floating_point<rep>::value è vero, oOriginal:std::chrono::treat_as_floating_point<rep>::value is true, orThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - std::chrono::treat_as_floating_point<Rep2>::value è falso.Original:std::chrono::treat_as_floating_point<Rep2>::value is false.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
-
@ @ (Cioè, con una durata di un conteggio intero non può essere costruito da un valore in virgola mobile, ma una durata con una virgola mobile conteggio può essere costruito da un valore intero)
Original:
@@(that is, a duration with an integer tick count cannot be constructed from a floating-point value, but a duration with a floating-point tick count can be constructed from an integer value)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
4)
Costruisce una durata convertendo
d
per un periodo adeguato e conteggio, come per std::chrono::duration_cast<duration>(d).count(). Al fine di evitare il troncamento durante la conversione, il costruttore partecipa solo se la risoluzione di sovraccarico:Original:
Constructs a duration by converting
d
to an appropriate period and tick count, as if by std::chrono::duration_cast<duration>(d).count(). In order to prevent truncation during conversion, this constructor only participates in overload resolution if:The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
- std::chrono::treat_as_floating_point<rep>::value == true
@ @ O di entrambi:
Original:
@@ or both:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
- std::ratio_divide<Period2, period>::den == 1, and
- std::chrono::treat_as_floating_point<Rep2>::value == false.
@ @ (Cioè, sia la durata utilizza virgola mobile zecche, o
Period2
è esattamente divisibile per periodo)Original:
@@ (that is, either the duration uses floating-point ticks, or
Period2
is exactly divisible by period)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[modifica] Parametri
r | - | un segno di spunta conteggio
Original: a tick count The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
d | - | una durata da cui copiare
Original: a duration to copy from The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[modifica] Esempio
Il codice seguente mostra alcuni esempi (sia validi e non validi) di come costruire le durate:
Original:
The following code shows several examples (both valid and invalid) of how to construct durations:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
#include <chrono> int main() { std::chrono::hours h(1); // one hour std::chrono::milliseconds ms{3}; // 3 milliseconds std::chrono::duration<int, std::kilo> ks(3); // 3000 seconds // error: treat_as_floating_point<int>::value == false, // This duration allows whole tick counts only // std::chrono::duration<int, std::kilo> d3(3.5); // 30Hz clock using fractional ticks std::chrono::duration<double, std::ratio<1, 30>> hz30(3.5); // 3000 microseconds constructed from 3 milliseconds std::chrono::microseconds us = ms; // error: 1/1000000 is not divisible by 1/1000 // std::chrono::milliseconds ms2 = us }
[modifica] Vedi anche
assegna il contenuto Original: assigns the contents The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) |