4.7 KiB
[time.clock.req]
30 Time library [time]
30.3 Cpp17Clock requirements [time.clock.req]
A clock is a bundle consisting of a duration, atime_point, and a function now() to get the current time_point.
The origin of the clock's time_point is referred to as the clock's epoch.
A clock shall meet the requirements in Table 131.
In Table 131 C1 and C2 denote clock types.
t1 andt2 are values returned by C1::now() where the call returning t1 happens before ([intro.multithread]) the call returning t2 and both of these calls occur before C1::time_point::max().
[Note 1:
This means C1 did not wrap around between t1 andt2.
â end note]
Table 131 — Cpp17Clock requirements [tab:time.clock]
| ð Expression |
Return type | Operational semantics |
|---|---|---|
| ð C1::rep |
An arithmetic type or a class emulating an arithmetic type | The representation type of C1::duration. |
| ð C1::period |
a specialization of ratio | The tick period of the clock in seconds. |
| ð C1::duration |
chrono::duration<C1::rep, C1::period> | The duration type of the clock. |
| ð C1::time_point |
chrono::time_point or chrono::time_point<C2, C1::duration> | The time_point type of the clock. C1 and C2 shall refer to the same epoch. |
| ð C1::is_steady |
const bool | true if t1 <= t2 is always true and the time between clock ticks is constant, otherwise false. |
| ð C1::now() |
C1::time_point | Returns a time_point object representing the current point in time. |
[Note 2:
The relative difference in durations between those reported by a given clock and the SI definition is a measure of the quality of implementation.
â end note]
A type TC meets the Cpp17TrivialClock requirements if
TC meets the Cpp17Clock requirements,
the types TC::rep, TC::duration, and TC::time_point meet the Cpp17EqualityComparable (Table 28) andCpp17LessThanComparable (Table 29) and Cpp17Swappable ([swappable.requirements]) requirements and the requirements of numeric types ([numeric.requirements]), [Note 3: This means, in particular, that operations on these types will not throw exceptions. â end note]
the function TC::now() does not throw exceptions, and
the type TC::time_point::clock meets the Cpp17TrivialClock requirements, recursively.