tetl 0.1.0
Embedded Template Library
|
Class template etl::chrono::duration represents a time interval. More...
#include <duration.hpp>
Public Types | |
using | period = typename Period::type |
A etl::ratio representing the tick period (i.e. the number of seconds per tick). | |
using | rep = Rep |
Rep, an arithmetic type representing the number of ticks. | |
Public Member Functions | |
constexpr | duration () noexcept=default |
Constructs a new duration from one of several optional data sources. The default constructor is defaulted. | |
constexpr | duration (duration const &) noexcept=default |
Constructs a new duration from one of several optional data sources. The copy constructor is defaulted (makes a bitwise copy of the tick count). | |
template<typename Rep2 , typename Period2 > requires ( treat_as_floating_point_v<rep> or (ratio_divide<Period2, period>::den == 1 and not treat_as_floating_point_v<Rep2>) ) | |
constexpr | duration (duration< Rep2, Period2 > const &other) noexcept |
Constructs a duration by converting d to an appropriate period and tick count, as if by duration_cast<duration>(d).count(). | |
template<typename Rep2 > requires (is_convertible_v<Rep2, rep> and (treat_as_floating_point_v<rep> or !treat_as_floating_point_v<Rep2>)) | |
constexpr | duration (Rep2 const &r) noexcept |
Constructs a duration with r ticks. | |
constexpr auto | count () const -> rep |
Returns the number of ticks for this duration. | |
constexpr auto | operator%= (duration const &rhs) noexcept -> duration & |
Performs compound assignments between two durations with the same period or between a duration and a tick count value. | |
constexpr auto | operator%= (rep const &rhs) noexcept -> duration & |
Performs compound assignments between two durations with the same period or between a duration and a tick count value. | |
constexpr auto | operator*= (rep const &rhs) noexcept -> duration & |
Performs compound assignments between two durations with the same period or between a duration and a tick count value. | |
constexpr auto | operator+ () const -> etl::common_type_t< duration > |
Implements unary plus and unary minus for the durations. | |
constexpr auto | operator++ () -> duration & |
Increments or decrements the number of ticks for this duration. Equivalent to ++_rep; return *this;. | |
constexpr auto | operator++ (int) -> duration |
Increments or decrements the number of ticks for this duration. Equivalent to return duration(_rep++) | |
constexpr auto | operator+= (duration const &d) noexcept -> duration & |
Performs compound assignments between two durations with the same period or between a duration and a tick count value. | |
constexpr auto | operator- () const -> etl::common_type_t< duration > |
Implements unary plus and unary minus for the durations. | |
constexpr auto | operator-- () -> duration & |
Increments or decrements the number of ticks for this duration. Equivalent to –_rep; return *this;. | |
constexpr auto | operator-- (int) -> duration |
Increments or decrements the number of ticks for this duration. Equivalent to return duration(_rep–);. | |
constexpr auto | operator-= (duration const &d) noexcept -> duration & |
Performs compound assignments between two durations with the same period or between a duration and a tick count value. | |
constexpr auto | operator/= (rep const &rhs) noexcept -> duration & |
Performs compound assignments between two durations with the same period or between a duration and a tick count value. | |
auto | operator= (duration const &other) -> duration &=default |
Assigns the contents of one duration to another. | |
Static Public Member Functions | |
static constexpr auto | max () noexcept -> duration |
Returns a duration with the largest possible value. | |
static constexpr auto | min () noexcept -> duration |
Returns a duration with the lowest possible value. | |
static constexpr auto | zero () noexcept -> duration |
Returns a zero-length duration. | |
Related Symbols | |
(Note that these are not member symbols.) | |
template<typename ToDur , typename Rep , typename Period > | |
constexpr auto | duration_cast (duration< Rep, Period > const &duration) noexcept(is_arithmetic_v< Rep > and is_arithmetic_v< typename ToDur::rep >) -> ToDur |
Converts a duration to a duration of different type ToDur. | |
Class template etl::chrono::duration represents a time interval.
It consists of a count of ticks of type Rep and a tick period, where the tick period is a compile-time rational constant representing the number of seconds from one tick to the next. The only data stored in a duration is a tick count of type Rep. If Rep is floating point, then the duration can represent fractions of ticks. Period is included as part of the duration's type, and is only used when converting between different durations.
A etl::ratio representing the tick period (i.e. the number of seconds per tick).
Rep, an arithmetic type representing the number of ticks.
Constructs a new duration from one of several optional data sources. The default constructor is defaulted.
Constructs a new duration from one of several optional data sources. The copy constructor is defaulted (makes a bitwise copy of the tick count).
|
inlineexplicitconstexprnoexcept |
Constructs a duration with r ticks.
Note that this constructor only participates in overload resolution if const Rep2& (the argument type) is implicitly convertible to rep (the type of this duration's ticks) and treat_as_floating_point<rep>::value is true, or 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
|
inlineconstexprnoexcept |
Constructs a duration by converting d to an appropriate period and tick count, as if by duration_cast<duration>(d).count().
In order to prevent truncation during conversion, this constructor only participates in overload resolution if computation of the conversion factor (by etl::ratio_divide<Period2, Period>) does not overflow and:
treat_as_floating_point<rep>::value == true
or both:
ratio_divide<Period2, period>::den == 1, and treat_as_floating_point<Rep2>::value == false
That is, either the duration uses floating-point ticks, or Period2 is exactly divisible by period
Returns the number of ticks for this duration.
Returns a duration with the largest possible value.
Returns a duration with the lowest possible value.
|
inlineconstexprnoexcept |
Performs compound assignments between two durations with the same period or between a duration and a tick count value.
Performs compound assignments between two durations with the same period or between a duration and a tick count value.
Performs compound assignments between two durations with the same period or between a duration and a tick count value.
|
inlineconstexpr |
Implements unary plus and unary minus for the durations.
Increments or decrements the number of ticks for this duration. Equivalent to ++_rep; return *this;.
Increments or decrements the number of ticks for this duration. Equivalent to return duration(_rep++)
Performs compound assignments between two durations with the same period or between a duration and a tick count value.
|
inlineconstexpr |
Implements unary plus and unary minus for the durations.
Increments or decrements the number of ticks for this duration. Equivalent to –_rep; return *this;.
Increments or decrements the number of ticks for this duration. Equivalent to return duration(_rep–);.
Performs compound assignments between two durations with the same period or between a duration and a tick count value.
Performs compound assignments between two durations with the same period or between a duration and a tick count value.
Assigns the contents of one duration to another.
Returns a zero-length duration.