27 Time library [time]

27.3 Cpp17Clock requirements [time.clock.req]

A clock is a bundle consisting of a duration, a time_­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 97.
In Table 97 C1 and C2 denote clock types.
t1 and t2 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().
This means C1 did not wrap around between t1 and t2.
— end note
Table 97: Cpp17Clock requirements   [tab:time.clock]
Return type
Operational semantics
An arithmetic type or a class emulating an arithmetic type
The representation type of C1​::​duration.
a specialization of ratio
The tick period of the clock in seconds.
chrono​::​duration<C1​::​rep, C1​::​period>
The duration type of the clock.
chrono​::​time_­point<C1> or chrono​::​time_­point<C2, C1​::​duration>
The time_­point type of the clock.
C1 and C2 shall refer to the same epoch.
const bool
true if t1 <= t2 is always true and the time between clock ticks is constant, otherwise false.
Returns a time_­point object representing the current point in time.
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 ([time.clock.req]),
  • the types TC​::​rep, TC​::​duration, and TC​::​time_­point meet the Cpp17EqualityComparable (Table 25) and Cpp17LessThanComparable (Table 26) requirements and the requirements of numeric types ([numeric.requirements]).
    : This means, in particular, that operations on these types will not throw exceptions. — end note
  • lvalues of the types TC​::​rep, TC​::​duration, and TC​::​time_­point are swappable ([swappable.requirements]),
  • the function TC​::​now() does not throw exceptions, and
  • the type TC​::​time_­point​::​clock meets the Cpp17TrivialClock requirements, recursively.