operator+,-,*,/,%(std::chrono::duration)
![]() | This page has been machine-translated from the English version of the wiki using Google Translate. The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
template<class Rep1, class Period1, class Rep2, class Period2 > typenamestd::common_type<duration<Rep1,Period1>, duration<Rep2,Period2>>::type | (1) | |
template<class Rep1, class Period1, class Rep2, class Period2 > typenamestd::common_type<duration<Rep1,Period1>, duration<Rep2,Period2>>::type | (2) | |
template<class Rep1, class Period, class Rep2 > duration<typenamestd::common_type<Rep1,Rep2>::type, Period> | (3) | |
template<class Rep1, class Rep2, class Period > duration<typenamestd::common_type<Rep1,Rep2>::type, Period> | (4) | |
template<class Rep1, class Period, class Rep2 > duration<typename common_type<Rep1,Rep2>::type, Period> | (5) | |
template<class Rep1, class Period1, class Rep2, class Period2 > typenamestd::common_type<Rep1,Rep2>::type | (6) | |
template<class Rep1, class Period, class Rep2 > duration<typename common_type<Rep1,Rep2>::type, Period> | (7) | |
template<class Rep1, class Period1, class Rep2, class Period2 > typename common_type<duration<Rep1,Period1>, duration<Rep2,Period2>>::type | (8) | |
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.
rhs
soustraits du nombre de tiques lhs
après conversion .rhs
number of ticks subtracted from the lhs
number of ticks after conversion.You can help to correct and verify the translation. Click here for instructions.
d
durée de celui dont rep
est le type commun entre Rep1
et Rep2
, et multiplie le nombre de tiques après conversion par s
.d
to one whose rep
is the common type between Rep1
and Rep2
, and multiples the number of ticks after conversion by s
.You can help to correct and verify the translation. Click here for instructions.
d
durée de celui dont rep
est le type commun entre Rep1
et Rep2
, et divise le nombre de tiques après conversion par s
d
to one whose rep
is the common type between Rep1
and Rep2
, and divides the number of ticks after conversion by s
You can help to correct and verify the translation. Click here for instructions.
lhs
après conversion par le nombre de cycles de rhs
après conversion. Notez que la valeur de retour de cet opérateur n'est pas une durée .lhs
after conversion by the tick count of rhs
after conversion. Note that the return value of this operator is not a duration.You can help to correct and verify the translation. Click here for instructions.
d
durée de celui dont rep
est le type commun entre Rep1
et Rep2
, et crée une durée dont tique total est le reste de la division du comte tique, après la conversion, par s
.d
to one whose rep
is the common type between Rep1
and Rep2
, and creates a duration whose tick count is the remainder of the division of the tick count, after conversion, by s
.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.
[modifier]Paramètres
lhs | - | durée sur le côté gauche de l'opérateur Original: duration on the left-hand side of the operator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
rhs | - | durée sur la partie droite de l'opérateur Original: duration on the right-hand side of the operator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
d | - | l'argument de durée mixte arguments opérateurs Original: the duration argument for mixed-argument operators The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
s | - | cochez compter argument en faveur de l'argument des opérateurs mixtes Original: tick count argument for mixed-argument operators The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[modifier]Retourne la valeur
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.
[modifier]Exemple
#include <chrono>#include <iostream>int main(){// simple arithmeticstd::chrono::seconds s =std::chrono::hours(1)+2*std::chrono::minutes(10)+std::chrono::seconds(70)/10; std::cout<<"1 hour + 2*10 min + 70/10 sec = "<< s.count()<<" seconds\n"; // difference between dividing a duration by a number// and dividing a duration by another durationstd::cout<<"Dividing that by 2 minutes gives "<< s /std::chrono::minutes(2)<<'\n';std::cout<<"Dividing that by 2 gives "<<(s /2).count()<<" sconds\n"; // the remainder operator is useful in determining where in a time// frame is this particular duration, e.g. to break it down into hours,// minutes, and seconds:std::cout<< s.count()<<" seconds is "<<std::chrono::duration_cast<std::chrono::hours>( s ).count()<<" hours, "<<std::chrono::duration_cast<std::chrono::minutes>( s %std::chrono::hours(1)).count()<<" minutes, "<<std::chrono::duration_cast<std::chrono::seconds>( s %std::chrono::minutes(1)).count()<<" seconds\n";}
Résultat :
1 hour + 2*10 min + 70/10 sec = 4807 seconds Dividing that by 2 minutes gives 40 Dividing that by 2 gives 2403 sconds 4807 seconds is 1 hours, 20 minutes, 7 seconds