std::chrono::duration::duration
From cppreference.com
| constexpr duration() = default; |
(1) | (since C++11) |
| duration( const duration& ) = default; |
(2) | (since C++11) |
| template< class Rep2 > constexpr explicit duration( const Rep2& r ); |
(3) | (since C++11) |
| template< class Rep2, class Period2 > constexpr duration( const duration<Rep2,Period2>& d ); |
(4) | (since C++11) |
Constructs a new duration from one of several optional data sources.
1) The default constructor is defaulted.
2) The copy constructor is defaulted (makes a bitwise copy of the tick count).
3) Constructs a duration with
r ticks. Note that this constructor only participates in overload resolution if Rep2 (the argument type) is implicitly convertible to rep (the type of this duration's ticks) and- std::chrono::treat_as_floating_point<rep>::value is true, or
- std::chrono::treat_as_floating_point<Rep2>::value is false.
(that is, a duration with an integer tick count cannot be constructed from a floating-point value, but a duration with a floating-point tick count can be constructed from an integer value)
4) Constructs a duration by converting
d to an appropriate period and tick count, as if by std::chrono::duration_cast<duration>(d).count(). In order to prevent truncation during conversion, this constructor only participates in overload resolution if no overflow is induced by conversion and:- std::chrono::treat_as_floating_point<rep>::value == true
or both:
- std::ratio_divide<Period2, period>::den == 1, and
- std::chrono::treat_as_floating_point<Rep2>::value == false.
(that is, either the duration uses floating-point ticks, or
Period2 is exactly divisible by period)Parameters
| r | - | a tick count |
| d | - | a duration to copy from |