class template
<chrono>

std::chrono::duration

template <class Rep, class Period = ratio<1> >
class duration;
Duration
A duration object expresses a time span by means of a count and a period.

Internally, the object stores the count as an object of member type rep (an alias of the first template parameter, Rep), which can be retrieved by calling member function count.

This count is expresed in terms of periods. The length of a period is integrated in the type (on compile time) by its second template parameter (Period), which is a ratio type that expresses the number (or fraction) of seconds that elapse in each period.

Template parameters

Rep
An arithmetic type, or a class emulating an arithmetic type, to be used as the type for the internal count.
Period
A ratio type that represents the period in seconds.

Template instantiations

The following convenience typedefs of instantiations of duration are also defined in this namespace:
typeRepresentationPeriod
hourssigned integral type of at least 23 bitsratio<3600,1>
minutessigned integral type of at least 29 bitsratio<60,1>
secondssigned integral type of at least 35 bitsratio<1,1>
millisecondssigned integral type of at least 45 bitsratio<1,1000>
microsecondssigned integral type of at least 55 bitsratio<1,1000000>
nanosecondssigned integral type of at least 64 bitsratio<1,1000000000>

Member types

The following aliases are member types of duration. They are widely used as parameter and return types by member functions:

member typedefinitionnotes
repThe first template parameter (Rep)Representation type used as the type for the internal count object.
periodThe second template parameter (Period)The ratio type that represents a period in seconds.

Member functions


static member functions


Non-member functions


See also