Time Duration
Time duration std::chrono::duration
is a class template that consists of the type of the tick Rep
and the length of a tick Period
.
template
<
class
Rep
,
class
Period
=
std
::
ratio
<
1
>
>
class
duration
;
The tick length is by default std::ratio<1>
. std::ratio<1>
stands for a second and can also be written as std::ratio<1, 1>
. The rest is quite easy. std::ratio<60>
is a minute and std::ratio<1,1000>
a millisecond. When the type of Rep
is a floating-point number, you can use it to hold fractions of time ticks.
C++11 predefines the most important time durations:
typedef
duration
<
signed
int
,
nano
>
nanoseconds
;
typedef
duration
<
signed
int
,
micro
>
microseconds
;
typedef
duration
<
signed
int
,
milli
>
milliseconds
;
typedef
duration
<
signed
int
>
seconds
;
typedef
duration
<
signed
int
,
ratio
<
60
>>
minutes
;
typedef
duration
<
signed...