mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Added documentation for clocks, day, duration
This commit is contained in:
parent
2d193ab309
commit
69d05198ec
@ -1,94 +1,123 @@
|
||||
Clocks
|
||||
Back to chrono
|
||||
____________________________________________________________________________________________________
|
||||
Macros
|
||||
Default macro definitions.
|
||||
Define these in etl_profile.h to set your own duration types for the clocks.
|
||||
---
|
||||
title: "Clocks"
|
||||
---
|
||||
|
||||
ETL_CHRONO_SYSTEM_CLOCK_DURATION etl::chrono::nanoseconds
|
||||
ETL_CHRONO_SYSTEM_CLOCK_IS_STEADY true
|
||||
ETL_CHRONO_HIGH_RESOLUTION_CLOCK_DURATION etl::chrono::nanoseconds
|
||||
ETL_CHRONO_HIGH_RESOLUTION_CLOCK_IS_STEADY true
|
||||
ETL_CHRONO_STEADY_CLOCK_DURATION etl::chrono::nanoseconds
|
||||
____________________________________________________________________________________________________
|
||||
Platform clock access
|
||||
## Macros
|
||||
Default macro definitions.
|
||||
Define these in `etl_profile.h` to set your own duration types for the clocks.
|
||||
|
||||
| Macro | Definition |
|
||||
| -------------------------------------------- | -------------------------- |
|
||||
| `ETL_CHRONO_SYSTEM_CLOCK_DURATION` | `etl::chrono::nanoseconds` |
|
||||
| `ETL_CHRONO_SYSTEM_CLOCK_IS_STEADY` | `true` |
|
||||
| `ETL_CHRONO_HIGH_RESOLUTION_CLOCK_DURATION` | `etl::chrono::nanoseconds` |
|
||||
| `ETL_CHRONO_HIGH_RESOLUTION_CLOCK_IS_STEADY` | `true` |
|
||||
| `ETL_CHRONO_STEADY_CLOCK_DURATION` | `etl::chrono::nanoseconds` |
|
||||
|
||||
## Platform clock access
|
||||
Declarations of the functions that must be defined to interface the clocks with the underlying platform.
|
||||
|
||||
```cpp
|
||||
extern "C" ETL_CHRONO_SYSTEM_CLOCK_DURATION::rep etl_get_system_clock();
|
||||
extern "C" ETL_CHRONO_HIGH_RESOLUTION_CLOCK_DURATION::rep etl_get_high_resolution_clock();
|
||||
extern "C" ETL_CHRONO_STEADY_CLOCK_DURATION::rep etl_get_steady_clock();
|
||||
```
|
||||
|
||||
These functions must return the current count of the underlying clock. The value is in terms of the
|
||||
clock duration defined for that clock.
|
||||
|
||||
Example:
|
||||
If the system_clock duration is set to etl::chrono::nanoseconds, then a return value of 1000 represents 1000ns.
|
||||
____________________________________________________________________________________________________
|
||||
system_clock
|
||||
**Example**
|
||||
If the `system_clock` duration is set to `etl::chrono::nanoseconds`, then a return value of `1000` represents `1000ns`.
|
||||
|
||||
## system_clock
|
||||
|
||||
```cpp
|
||||
class system_clock
|
||||
```
|
||||
|
||||
Member types
|
||||
### Member types
|
||||
```cpp
|
||||
using duration = ETL_CHRONO_SYSTEM_CLOCK_DURATION
|
||||
using rep = duration::rep
|
||||
using period = duration::period
|
||||
using time_point = time_point<system_clock, duration>
|
||||
```
|
||||
|
||||
Member functions
|
||||
### Member functions
|
||||
```cpp
|
||||
static time_point now() ETL_NOEXCEPT
|
||||
static time_t to_time_t(const time_point& t) ETL_NOEXCEPT
|
||||
static time_point from_time_t(time_t t) ETL_NOEXCEPT
|
||||
____________________________________________________________________________________________________
|
||||
high_resolution_clock
|
||||
```
|
||||
|
||||
## high_resolution_clock
|
||||
```cpp
|
||||
class high_resolution_clock
|
||||
```
|
||||
|
||||
Member types
|
||||
### Member types
|
||||
```cpp
|
||||
using duration = ETL_CHRONO_HIGH_RESOLUTION_CLOCK_DURATION
|
||||
using rep = duration::rep
|
||||
using period = duration::period
|
||||
using time_point = time_point<high_resolution_clock, duration>
|
||||
```
|
||||
|
||||
Member functions
|
||||
### Member functions
|
||||
```cpp
|
||||
static time_point now() ETL_NOEXCEPT
|
||||
____________________________________________________________________________________________________
|
||||
steady_clock
|
||||
```
|
||||
|
||||
## steady_clock
|
||||
```cpp
|
||||
class steady_clock
|
||||
```
|
||||
|
||||
Member types
|
||||
### Member types
|
||||
```cpp
|
||||
using duration = ETL_CHRONO_STEADY_CLOCK_DURATION
|
||||
using rep = duration::rep
|
||||
using period = duration::period
|
||||
using time_point = time_point<steady_clock, duration>
|
||||
```
|
||||
|
||||
Member functions
|
||||
### Member functions
|
||||
```cpp
|
||||
static time_point now() ETL_NOEXCEPT
|
||||
____________________________________________________________________________________________________
|
||||
system_time
|
||||
```
|
||||
|
||||
## system_time
|
||||
```cpp
|
||||
template <typename Duration>
|
||||
using sys_time = etl::chrono::time_point<etl::chrono::system_clock, Duration>
|
||||
|
||||
using sys_seconds = sys_time<etl::chrono::seconds>
|
||||
using sys_days = sys_time<etl::chrono::days>
|
||||
____________________________________________________________________________________________________
|
||||
local_time
|
||||
```
|
||||
|
||||
## local_time
|
||||
```cpp
|
||||
struct local_t
|
||||
```
|
||||
|
||||
```cpp
|
||||
template <typename TDuration>
|
||||
using local_time = etl::chrono::time_point<etl::chrono::local_t, TDuration>
|
||||
|
||||
using local_seconds = local_time<etl::chrono::seconds>
|
||||
using local_days = local_time<etl::chrono::days>
|
||||
____________________________________________________________________________________________________
|
||||
clock_cast
|
||||
```
|
||||
|
||||
Cast a time point from one clock to another.
|
||||
## clock_cast
|
||||
|
||||
Cast a time point from one clock to another.
|
||||
This implementation assumes all clock epochs are the same.
|
||||
|
||||
template <typename TToClock, typename TFromClock, typename TFromDuration>
|
||||
ETL_CONSTEXPR14 etl::chrono::time_point<TToClock, typename TToClock::duration>
|
||||
```cpp
|
||||
template <typename TToClock,
|
||||
typename TFromClock,
|
||||
typename TFromDuration>
|
||||
ETL_CONSTEXPR14 etl::chrono::time_point<TToClock,
|
||||
typename TToClock::duration>
|
||||
clock_cast(const etl::chrono::time_point<TFromClock, TFromDuration>& from_time_point) ETL_NOEXCEPT
|
||||
|
||||
```
|
||||
@ -1,181 +1,297 @@
|
||||
day
|
||||
---
|
||||
title: "day"
|
||||
---
|
||||
|
||||
{{< callout type="info">}}
|
||||
Header: `chrono.h`
|
||||
Supported: `TBC`
|
||||
Similar to: [std::chrono::day](https://en.cppreference.com/w/cpp/chrono/day.html)
|
||||
{{< /callout >}}
|
||||
|
||||
A template representing a day.
|
||||
Back to chrono
|
||||
____________________________________________________________________________________________________
|
||||
day
|
||||
|
||||
STL equivalent: std::chrono::day
|
||||
|
||||
```cpp
|
||||
class day
|
||||
____________________________________________________________________________________________________
|
||||
Typesdefs
|
||||
rep The internal representation.
|
||||
____________________________________________________________________________________________________
|
||||
Construction
|
||||
```
|
||||
|
||||
## Typesdefs
|
||||
rep The internal representation.
|
||||
|
||||
## Construction
|
||||
```cpp
|
||||
ETL_CONSTEXPR
|
||||
day()
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Default constructor.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
```cpp
|
||||
ETL_CONSTEXPR
|
||||
explicit day(unsigned value)
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Construct from unsigned.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
day(const etl::chrono::day& other)
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Copy constructor.
|
||||
____________________________________________________________________________________________________
|
||||
Tests
|
||||
|
||||
## Tests
|
||||
```cpp
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
bool ok() const
|
||||
ETL_NOEXCEPT
|
||||
Returns true if the day is within the valid range.
|
||||
______________________________________________
|
||||
```
|
||||
**Return**
|
||||
`true` if the day is within the valid range.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
int compare(const etl::chrono::day& other) const
|
||||
ETL_NOEXCEPT
|
||||
Compare day with another.
|
||||
if day < other, returns -1
|
||||
else if day > other, returns 1
|
||||
else returns 0
|
||||
____________________________________________________________________________________________________
|
||||
Assignment
|
||||
```
|
||||
**Description**
|
||||
Compare `day` with another.
|
||||
if `day < other`, returns `-1`
|
||||
else if `day > other`, returns `1`
|
||||
else returns `0`
|
||||
|
||||
## Assignment
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
etl::chrono::day& operator =(const etl::chrono::day& rhs)
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Assignment operator
|
||||
____________________________________________________________________________________________________
|
||||
Increment/decrement
|
||||
|
||||
## Increment/decrement
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
etl::chrono::day& operator ++()
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Pre-increment operator.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
etl::chrono::day operator ++(int)
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Post-increment operator.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
etl::chrono::day& operator --()
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Pre-decrement operator.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
etl::chrono::day operator --(int)
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Post-decrement operator.
|
||||
____________________________________________________________________________________________________
|
||||
Mathematical operators
|
||||
|
||||
## Mathematical operators
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
etl::chrono::day& operator +=(const etl::chrono::days& ms)
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Plus-equals operator adding etl::chrono::days.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
etl::chrono::day& operator -=(const etl::chrono::days& ms)
|
||||
ETL_NOEXCEPT
|
||||
Minus-equals operator subtracting etl::chrono::days.
|
||||
____________________________________________________________________________________________________
|
||||
Conversion
|
||||
```
|
||||
**Description**
|
||||
Minus-equals operator subtracting `etl::chrono::days`.
|
||||
|
||||
## Conversion
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
operator unsigned() const
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Conversion operator to unsigned int.
|
||||
____________________________________________________________________________________________________
|
||||
Non-member mathematical operators
|
||||
|
||||
## Non-member mathematical operators
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
etl::chrono::day operator +(const etl::chrono::day& m,
|
||||
const etl::chrono::days& ms)
|
||||
ETL_NOEXCEPT
|
||||
Add etl::chrono::days to etl::chrono::day.
|
||||
Returns etl::chrono::day.
|
||||
______________________________________________
|
||||
```
|
||||
**Description**
|
||||
Add `etl::chrono::days` to `etl::chrono::day`.
|
||||
|
||||
**Return**
|
||||
`etl::chrono::day.`
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
etl::chrono::day operator +(const etl::chrono::days& ms,
|
||||
const etl::chrono::day& m)
|
||||
ETL_NOEXCEPT
|
||||
Add etl::chrono::day to etl::chrono::days.
|
||||
Returns etl::chrono::day.
|
||||
______________________________________________
|
||||
```
|
||||
**Description**
|
||||
Add `etl::chrono::day` to `etl::chrono::days`.
|
||||
|
||||
**Return**
|
||||
`etl::chrono::day`.
|
||||
|
||||
---
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
etl::chrono::day operator -(const etl::chrono::day& m,
|
||||
const etl::chrono::days& ms)
|
||||
ETL_NOEXCEPT
|
||||
Subtract etl::chrono::days from etl::chrono::day.
|
||||
Returns etl::chrono::day.
|
||||
______________________________________________
|
||||
```
|
||||
**Description**
|
||||
Subtract `etl::chrono::days` from `etl::chrono::day`.
|
||||
|
||||
**Return**
|
||||
`etl::chrono::day`.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
etl::chrono::day operator -(const etl::chrono::days& ms,
|
||||
const etl::chrono::day& m)
|
||||
ETL_NOEXCEPT
|
||||
Subtract etl::chrono::day from etl::chrono::days.
|
||||
Returns etl::chrono::days.
|
||||
______________________________________________
|
||||
```
|
||||
**Description**
|
||||
Subtract `etl::chrono::day` from `etl::chrono::days`.
|
||||
|
||||
**Return**
|
||||
`etl::chrono::days`.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
etl::chrono::days operator -(const etl::chrono::day& m1,
|
||||
const etl::chrono::day& m2) ETL_NOEXCEPT
|
||||
Subtract etl::chrono::day from etl::chrono::day.
|
||||
Returns etl::chrono::days.
|
||||
____________________________________________________________________________________________________
|
||||
Non-member comparison operators
|
||||
```
|
||||
**Description**
|
||||
Subtract `etl::chrono::day` from `etl::chrono::day`.
|
||||
|
||||
**Return**
|
||||
`etl::chrono::days`.
|
||||
|
||||
## Non-member comparison operators
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
bool operator ==(const etl::chrono::day& m1,
|
||||
const etl::chrono::day& m2)
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Equality operator.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
bool operator !=(const etl::chrono::day& m1,
|
||||
const etl::chrono::day& m2)
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Inequality operator.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
bool operator <(const etl::chrono::day& m1,
|
||||
const etl::chrono::day& m2)
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Less-than operator.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
bool operator <=(const etl::chrono::day& m1,
|
||||
const etl::chrono::day& m2)
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Less-than-or-equal operator.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
bool operator >(const etl::chrono::day& m1,
|
||||
const etl::chrono::day& m2)
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Greater-than operator.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
bool operator >=(const etl::chrono::day& m1,
|
||||
const etl::chrono::day& m2)
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Greater-than-or-equal operator.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
[[nodiscard]] inline constexpr
|
||||
auto operator <=>(const etl::chrono::day& m1,
|
||||
const etl::chrono::day& m2)
|
||||
noexcept
|
||||
```
|
||||
**Description**
|
||||
Spaceship operator.
|
||||
C++20
|
||||
____________________________________________________________________________________________________
|
||||
Defined days
|
||||
|
||||
## Defined days
|
||||
|
||||
```cpp
|
||||
etl::chrono::January
|
||||
etl::chrono::February
|
||||
etl::chrono::March
|
||||
@ -188,10 +304,14 @@ etl::chrono::September
|
||||
etl::chrono::October
|
||||
etl::chrono::November
|
||||
etl::chrono::December
|
||||
____________________________________________________________________________________________________
|
||||
Hash
|
||||
```
|
||||
|
||||
## Hash
|
||||
|
||||
```cpp
|
||||
template <>
|
||||
struct hash<etl::chrono::day>
|
||||
Hash function for etl::chrono::day
|
||||
```
|
||||
**Description**
|
||||
Hash function for `etl::chrono::day`.
|
||||
|
||||
@ -1,184 +1,299 @@
|
||||
duration
|
||||
Templates representing a time intervals.
|
||||
Back to chrono
|
||||
____________________________________________________________________________________________________
|
||||
duration_values
|
||||
---
|
||||
title: "duration"
|
||||
---
|
||||
|
||||
STL equivalent: std::chrono::duration_values
|
||||
{{< callout type="info">}}
|
||||
Header: `chrono.h`
|
||||
Supported: `TBC`
|
||||
Similar to: [std::chrono::duration](https://en.cppreference.com/w/cpp/chrono/duration.html)
|
||||
Similar to: [std::chrono::duration_values](https://en.cppreference.com/w/cpp/chrono/duration_values.html)
|
||||
{{< /callout >}}
|
||||
|
||||
Templates representing a time interval.
|
||||
|
||||
## duration_values
|
||||
```cpp
|
||||
template <typename TRep>
|
||||
struct duration_values
|
||||
|
||||
```
|
||||
```cpp
|
||||
ETL_NODISCARD static ETL_CONSTEXPR TRep zero() ETL_NOEXCEPT
|
||||
Returns TRep(0)
|
||||
______________________________________________
|
||||
```
|
||||
**Return**
|
||||
`TRep(0)`
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_NODISCARD static ETL_CONSTEXPR14 TRep min() ETL_NOEXCEPT
|
||||
Returns etl::numeric_limits<TRep>::min()
|
||||
______________________________________________
|
||||
```
|
||||
**Return**
|
||||
`etl::numeric_limits<TRep>::min()`
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_NODISCARD static ETL_CONSTEXPR14 TRep max() ETL_NOEXCEPT
|
||||
Returns etl::numeric_limits<TRep>::max()
|
||||
|
||||
____________________________________________________________________________________________________
|
||||
duration
|
||||
|
||||
STL equivalent: std::chrono::duration
|
||||
```
|
||||
**Returns**
|
||||
`etl::numeric_limits<TRep>::max()`
|
||||
|
||||
## duration
|
||||
```cpp
|
||||
template <typename TRep, typename TPeriod = etl::ratio<1>>
|
||||
class duration
|
||||
______________________________________________
|
||||
```
|
||||
```cpp
|
||||
using rep = TRep
|
||||
using period = typename TPeriod::type;
|
||||
____________________________________________________________________________________________________
|
||||
Construction
|
||||
```
|
||||
|
||||
## Construction
|
||||
```cpp
|
||||
ETL_CONSTEXPR
|
||||
duration()
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Default constructor.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
duration(const etl::chrono::duration<TRep, TPeriod>& other)
|
||||
ETL_NOEXCEPT
|
||||
______________________________________________
|
||||
```
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TRep2>
|
||||
ETL_CONSTEXPR14
|
||||
explicit duration(const TRep2& value)
|
||||
ETL_NOEXCEPT
|
||||
______________________________________________
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TRep2, typename TPeriod2>
|
||||
ETL_CONSTEXPR14
|
||||
duration(const etl::chrono::duration<TRep2, TPeriod2>& other)
|
||||
ETL_NOEXCEPT
|
||||
Construct from another duration type.
|
||||
Enabled if etl::ratio_divide<TPeriod2, TPeriod>::den == 1
|
||||
____________________________________________________________________________________________________
|
||||
Tests
|
||||
```
|
||||
**Description**
|
||||
Construct from another duration type.
|
||||
Enabled if `etl::ratio_divide<TPeriod2, TPeriod>::den == 1`
|
||||
|
||||
## Tests
|
||||
```cpp
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
int compare(const time_point& other) const
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Compare day with another.
|
||||
if time_point < other, returns -1
|
||||
else if time_point > other, returns 1
|
||||
else returns 0
|
||||
____________________________________________________________________________________________________
|
||||
Assignment
|
||||
if `time_point < other`, returns `-1`
|
||||
else if `time_point > other`, returns `1`
|
||||
else returns `0`
|
||||
|
||||
## Assignment
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
etl::chrono::duration<TRep, TPeriod> operator =(const etl::chrono::duration<TRep, TPeriod>& other) ETL_NOEXCEPT
|
||||
______________________________________________
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TRep2, typename TPeriod2>
|
||||
ETL_CONSTEXPR14
|
||||
etl::chrono::duration<TRep, TPeriod> operator =(const etl::chrono::duration<TRep2, TPeriod2>& other) ETL_NOEXCEPT
|
||||
____________________________________________________________________________________________________
|
||||
Convertion
|
||||
```
|
||||
|
||||
## Convertion
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
TRep count() const
|
||||
ETL_NOEXCEPT
|
||||
Returns the duration count as a numeric.
|
||||
______________________________________________
|
||||
```
|
||||
**Return**
|
||||
The duration count as a numeric.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
etl::common_type_t<duration> operator +() const
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Implements unary plus.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
etl::common_type_t<duration> operator -() const
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Implements unary minus.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
etl::chrono::duration<TRep, TPeriod> absolute() const
|
||||
ETL_NOEXCEPT
|
||||
Returns the absolute value of the duration.
|
||||
____________________________________________________________________________________________________
|
||||
Constants
|
||||
```
|
||||
**Return**
|
||||
The absolute value of the duration.
|
||||
|
||||
---
|
||||
|
||||
## Constants
|
||||
```cpp
|
||||
ETL_NODISCARD
|
||||
static ETL_CONSTEXPR14 etl::chrono::duration<TRep, TPeriod> zero()
|
||||
ETL_NOEXCEPT
|
||||
Returns the duration zero value.
|
||||
______________________________________________
|
||||
```
|
||||
**Return**
|
||||
The duration zero value.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_NODISCARD
|
||||
static ETL_CONSTEXPR14 etl::chrono::duration<TRep, TPeriod> min()
|
||||
ETL_NOEXCEPT
|
||||
Returns the minimum duration value.
|
||||
______________________________________________
|
||||
```
|
||||
**Return**
|
||||
The minimum duration value.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_NODISCARD
|
||||
static ETL_CONSTEXPR14 etl::chrono::duration<TRep, TPeriod> max()
|
||||
ETL_NOEXCEPT
|
||||
Returns the maximum duration value.
|
||||
____________________________________________________________________________________________________
|
||||
Increment/decrement
|
||||
---
|
||||
**Return**
|
||||
The maximum duration value.
|
||||
|
||||
## Increment/decrement
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
duration& operator ++()
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Pre-increments the duration count.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
duration operator ++(int)
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Post-increments the duration count.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
duration& operator --()
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Pre-decrements the duration count.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
duration operator --(int)
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Post-decrements the duration count.
|
||||
____________________________________________________________________________________________________
|
||||
Mathematical operators
|
||||
|
||||
## Mathematical operators
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
duration& operator +=(const duration<TRep, TPeriod>& d)
|
||||
ETL_NOEXCEPT
|
||||
Adds duration d to this duration.
|
||||
______________________________________________
|
||||
```
|
||||
**Description**
|
||||
Adds duration `d` to this duration.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
duration& operator -=(const duration<TRep, TPeriod>& d)
|
||||
ETL_NOEXCEPT
|
||||
Subtracts duration d to this duration.
|
||||
______________________________________________
|
||||
```
|
||||
**Description**
|
||||
Subtracts duration `d` to this duration.
|
||||
|
||||
---
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
duration& operator *=(const TRep& r)
|
||||
ETL_NOEXCEPT
|
||||
Multiplies this duration by r.
|
||||
______________________________________________
|
||||
```
|
||||
**Description**
|
||||
Multiplies this duration by `r`.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
duration& operator /=(const TRep& r)
|
||||
ETL_NOEXCEPT
|
||||
Divides this duration by r.
|
||||
______________________________________________
|
||||
```
|
||||
**Description**
|
||||
Divides this duration by `r`.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
duration& operator %=(const TRep& r)
|
||||
ETL_NOEXCEPT
|
||||
Sets this duration to the modulus of r.
|
||||
______________________________________________
|
||||
```
|
||||
**Description**
|
||||
Sets this duration to the modulus of `r`.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14
|
||||
duration& operator %=(const duration<TRep, TPeriod>& d)
|
||||
ETL_NOEXCEPT
|
||||
Sets this duration to the modulus of duration d.
|
||||
____________________________________________________________________________________________________
|
||||
Comparison
|
||||
```
|
||||
**Description**
|
||||
Sets this duration to the modulus of duration `d`.
|
||||
|
||||
## Comparison
|
||||
```cpp
|
||||
template <typename TRep2, typename TPeriod2>
|
||||
ETL_CONSTEXPR14
|
||||
int compare(const duration<TRep2, TPeriod2>& other) const
|
||||
ETL_NOEXCEPT
|
||||
Compare duration with another.
|
||||
If duration < other, returns -1
|
||||
else if duration > other, returns 1
|
||||
else returns 0
|
||||
____________________________________________________________________________________________________
|
||||
Non-member mathematical operators
|
||||
```
|
||||
**Description**
|
||||
Compare duration with another.
|
||||
If `duration < other`, returns `-1`
|
||||
else if `duration > other`, returns `1`
|
||||
else returns `0`
|
||||
|
||||
## Non-member mathematical operators
|
||||
```cpp
|
||||
template <typename TRep1, typename TPeriod1, typename TRep2, typename TPeriod2>
|
||||
ETL_CONSTEXPR14
|
||||
etl::common_type_t<etl::chrono::duration<TRep1, TPeriod1>,
|
||||
@ -186,8 +301,13 @@ etl::common_type_t<etl::chrono::duration<TRep1, TPeriod1>,
|
||||
operator +(const etl::chrono::duration<TRep1, TPeriod1>& lhs,
|
||||
const etl::chrono::duration<TRep2, TPeriod2>& rhs)
|
||||
ETL_NOEXCEPT
|
||||
Operator +
|
||||
______________________________________________
|
||||
```
|
||||
**Description**
|
||||
Operator `+`
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TRep1, typename TPeriod1, typename TRep2, typename TPeriod2>
|
||||
ETL_CONSTEXPR14
|
||||
etl::common_type_t<etl::chrono::duration<TRep1, TPeriod1>,
|
||||
@ -195,50 +315,80 @@ etl::common_type_t<etl::chrono::duration<TRep1, TPeriod1>,
|
||||
operator -(const etl::chrono::duration<TRep1, TPeriod1>& lhs,
|
||||
const etl::chrono::duration<TRep2, TPeriod2>& rhs)
|
||||
ETL_NOEXCEPT
|
||||
Operator -
|
||||
______________________________________________
|
||||
```
|
||||
**Description**
|
||||
Operator `-`
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TRep1, typename TPeriod1, typename TRep2>
|
||||
ETL_CONSTEXPR14
|
||||
etl::chrono::duration<etl::common_type_t<TRep1, TRep2>, TPeriod1>>
|
||||
operator *(const etl::chrono::duration<TRep1, TPeriod1>& lhs,
|
||||
const TRep2& rhs)
|
||||
ETL_NOEXCEPT
|
||||
Operator *
|
||||
Enabled if TRep2 is not a specialization of etl::chrono::duration.
|
||||
______________________________________________
|
||||
```
|
||||
**Description**
|
||||
Operator `*`
|
||||
Enabled if `TRep2` is not a specialization of `etl::chrono::duration`.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TRep1, typename TRep2, typename TPeriod2>
|
||||
ETL_CONSTEXPR14
|
||||
etl::chrono::duration<etl::common_type_t<TRep1, TRep2>, TPeriod2>
|
||||
operator *(const TRep1& lhs,
|
||||
const etl::chrono::duration<TRep2, TPeriod2>& rhs)
|
||||
ETL_NOEXCEPT
|
||||
Operator *
|
||||
______________________________________________
|
||||
```
|
||||
**Description**
|
||||
Operator `*`
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TRep1, typename TPeriod1, typename TRep2>
|
||||
ETL_CONSTEXPR14
|
||||
etl::common_type_t<TRep1, TRep2>, TPeriod1>
|
||||
operator /(const etl::chrono::duration<TRep1, TPeriod1>& lhs,
|
||||
const TRep2& rhs)
|
||||
ETL_NOEXCEPT
|
||||
Operator /
|
||||
Enabled if TRep2 is not a specialization of etl::chrono::duration.
|
||||
______________________________________________
|
||||
```
|
||||
**Description**
|
||||
Operator `/`
|
||||
Enabled if `TRep2` is not a specialization of `etl::chrono::duration`.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TRep1, typename TPeriod1, typename TRep2, typename TPeriod2>
|
||||
ETL_CONSTEXPR14
|
||||
etl::common_type_t<TRep1, TRep2>
|
||||
operator /(const etl::chrono::duration<TRep1, TPeriod1>& lhs,
|
||||
const etl::chrono::duration<TRep2, TPeriod2>& rhs)
|
||||
ETL_NOEXCEPT
|
||||
Operator /
|
||||
______________________________________________
|
||||
```
|
||||
**Description**
|
||||
Operator `/`
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TRep1, typename TPeriod1, typename TRep2>
|
||||
ETL_CONSTEXPR14
|
||||
etl::chrono::duration<etl::common_type_t<TRep1, TRep2>, TPeriod1>
|
||||
operator %(const etl::chrono::duration<TRep1, TPeriod1>& lhs,
|
||||
const TRep2& rhs)
|
||||
ETL_NOEXCEPT
|
||||
Operator %
|
||||
______________________________________________
|
||||
```
|
||||
**Description**
|
||||
Operator `%`
|
||||
|
||||
```
|
||||
|
||||
```cpp
|
||||
template <typename TRep1, typename TPeriod1, typename TRep2, typename TPeriod2>
|
||||
ETL_CONSTEXPR14
|
||||
etl::common_type_t<etl::chrono::duration<TRep1, TPeriod1>,
|
||||
@ -246,74 +396,113 @@ etl::common_type_t<etl::chrono::duration<TRep1, TPeriod1>,
|
||||
operator %(const etl::chrono::duration<TRep1, TPeriod1>& lhs,
|
||||
const etl::chrono::duration<TRep2, TPeriod2>& rhs)
|
||||
ETL_NOEXCEPT
|
||||
Operator %
|
||||
____________________________________________________________________________________________________
|
||||
Non-member comparison operators
|
||||
```
|
||||
**Description**
|
||||
Operator `%`
|
||||
|
||||
## Non-member comparison operators
|
||||
```cpp
|
||||
template <typename TRep1, typename TPeriod1, typename TRep2, typename TPeriod2>
|
||||
ETL_CONSTEXPR14
|
||||
bool operator ==(const etl::chrono::duration<TRep1, TPeriod1>& lhs,
|
||||
const etl::chrono::duration<TRep2, TPeriod2>& rhs)
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Checks for equality.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TRep1, typename TPeriod1, typename TRep2, typename TPeriod2>
|
||||
ETL_CONSTEXPR14
|
||||
bool operator !=(const etl::chrono::duration<TRep1, TPeriod1>& lhs,
|
||||
const etl::chrono::duration<TRep2, TPeriod2>& rhs)
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Checks for inequality.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TRep1, typename TPeriod1, typename TRep2, typename TPeriod2>
|
||||
ETL_CONSTEXPR14
|
||||
bool operator <(const etl::chrono::duration<TRep1, TPeriod1>& lhs,
|
||||
const etl::chrono::duration<TRep2, TPeriod2>& rhs)
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Checks for less-than.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TRep1, typename TPeriod1, typename TRep2, typename TPeriod2>
|
||||
ETL_CONSTEXPR14
|
||||
bool operator <=(const etl::chrono::duration<TRep1, TPeriod1>& lhs,
|
||||
const etl::chrono::duration<TRep2, TPeriod2>& rhs)
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Checks for less-than-or-equal.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TRep1, typename TPeriod1, typename TRep2, typename TPeriod2>
|
||||
ETL_CONSTEXPR14
|
||||
bool operator >(const etl::chrono::duration<TRep1, TPeriod1>& lhs,
|
||||
const etl::chrono::duration<TRep2, TPeriod2>& rhs)
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Checks for greater-than.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TRep1, typename TPeriod1, typename TRep2, typename TPeriod2>
|
||||
ETL_CONSTEXPR14
|
||||
bool operator >=(const etl::chrono::duration<TRep1, TPeriod1>& lhs,
|
||||
const etl::chrono::duration<TRep2, TPeriod2>& rhs)
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Checks for greater-than-or-equal.
|
||||
______________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TRep1, typename TPeriod1, typename TRep2, typename TPeriod2>
|
||||
[[nodiscard]]
|
||||
constexpr
|
||||
auto operator <=>(const etl::chrono::duration<TRep1, TPeriod1>& lhs,
|
||||
const etl::chrono::duration<TRep2, TPeriod2>& rhs)
|
||||
noexcept
|
||||
Spaceship operator.
|
||||
```
|
||||
**Description**
|
||||
Spaceship operator.
|
||||
C++20
|
||||
____________________________________________________________________________________________________
|
||||
common_type
|
||||
|
||||
## common_type
|
||||
|
||||
```cpp
|
||||
template <typename TRep1, typename TPeriod1, typename TRep2, typename TPeriod2>
|
||||
struct common_type<etl::chrono::duration<TRep1, TPeriod1>, etl::chrono::duration<TRep2, TPeriod2>>
|
||||
etl::common_type specialisation for etl::duration.
|
||||
____________________________________________________________________________________________________
|
||||
Hash
|
||||
```
|
||||
**Description**
|
||||
`etl::common_type` specialisation for `etl::duration`.
|
||||
|
||||
## Hash
|
||||
```cpp
|
||||
template <typename TRep, typename TPeriod>
|
||||
struct hash<etl::chrono::duration<TRep, TPeriod>>
|
||||
____________________________________________________________________________________________________
|
||||
Pre-defined duration types
|
||||
```
|
||||
|
||||
## Pre-defined duration types
|
||||
|
||||
```cpp
|
||||
etl::chrono::years
|
||||
etl::chrono::months
|
||||
etl::chrono::weeks
|
||||
@ -324,12 +513,14 @@ etl::chrono::seconds
|
||||
etl::chrono::milliseconds
|
||||
etl::chrono::microseconds
|
||||
etl::chrono::nanoseconds
|
||||
____________________________________________________________________________________________________
|
||||
duration_cast
|
||||
```
|
||||
|
||||
## duration_cast
|
||||
```cpp
|
||||
template <typename TToDuration, typename TRep, typename TPeriod>
|
||||
ETL_CONSTEXPR14
|
||||
TToDuration duration_cast(const etl::chrono::duration<TRep, TPeriod>& d)
|
||||
ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Converts from one duration type to another.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user