duration Class

Describes a type that holds a time interval, which is an elapsed time between two time points.

template<
   class Rep,
   class Period = ratio<1>
>
class duration;
template<
   class Rep,
   class Period
>
class duration;
template<
   class Rep,
   class Period1,
   class Period2
>
class duration
   <duration<Rep, Period1>, Period2>;

Remarks

The template argument Rep describes the type that is used to hold the number of clock ticks in the interval. The template argument Period is an instantiation of ratio that describes the size of the interval that each tick represents.

Members

Public Typedefs

Name

Description

duration::period Typedef

Represents a synonym for the template parameter Period.

duration::rep Typedef

Represents a synonym for the template parameter Rep.

Public Constructors

Name

Description

duration::duration Constructor

Constructs a duration object.

Public Methods

Name

Description

duration::count Method

Returns the number of clock ticks in the time interval.

duration::max Method

Static. Returns the maximum allowable value of template parameter Ref.

duration::min Method

Static. Returns the lowest allowable value of template parameter Ref.

duration::zero Method

Static. In effect, returns Rep(0).

Public Operators

Name

Description

duration::operator- Operator

Returns a copy of the duration object together with a negated tick count.

duration::operator-- Operator

Decrements the stored tick count.

duration::operator= Operator

Reduces the stored tick count modulo a specified value.

duration::operator*= Operator

Multiplies the stored tick count by a specified value.

duration::operator/= Operator

Divides the stored tick count by the tick count of a specified duration object.

duration::operator+ Operator

Returns *this.

duration::operator++ Operator

Increments the stored tick count.

duration::operator+= Operator

Adds the tick count of a specified duration object to the stored tick count.

duration::operator-= Operator

Subtracts the tick count of a specified duration object from the stored tick count.

Requirements

Header: chrono

Namespace: std::chrono

See Also

Reference

<chrono>

duration_values Structure

Other Resources

C++ Standard Library Header Files