Megosztás a következőn keresztül:


duration::duration Constructor

Constructs a duration object.

constexpr duration();
template<class Rep2>
    constexpr explicit duration(const Rep2& R);
template<class Rep2, class Period2>
    constexpr duration(const duration<Rep2, Period2>& Dur);

Remarks

The first constructor constructs an object that represents a time interval of zero clock ticks.

The second constructor constructs an object that represents a time interval of R clock ticks. To avoid round-off of tick counts, it is an error to construct a duration object from a representation type Rep2 that can be treated as a floating-point type when duration::rep cannot be treated as a floating-point type.

The third constructor constructs an object that represents a time interval whose length is the time interval that is specified by Dur. To avoid truncation of tick counts, it is an error to construct a duration object from another duration object whose type is incommensurable with the target type.

A duration type D1 is incommensurable with another duration type D2 if D2 cannot be treated as a floating-point type and ratio_divide<D1::period, D2::period>::type::den is not 1.

Unless treat_as_floating_point<Rep>holds true and treat_as_floating_point<Rep2>holds false, the second constructor does not participate in overload resolution. For more information, see <type_traits>.

Unless treat_as_floating_point<Rep>holds true and treat_as_floating_point<Rep2>, or both ratio_divide<Period2, period>::den equals 1 and treat_as_floating_point<Rep2>holds false, the third constructor does not participate in overload resolution. For more information, see <type_traits>.

Requirements

Header: chrono

Namespace: std::chrono

See Also

Reference

duration Class

<chrono>

treat_as_floating_point Structure