Files
2025-10-25 03:02:53 +03:00

84 lines
4.7 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[time.clock.req]
# 30 Time library [[time]](./#time)
## 30.3 *Cpp17Clock* requirements [time.clock.req]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L976)
A clock is a bundle consisting of a duration, atime_point, and a function now() to get the current time_point[.](#1.sentence-1)
The origin of the clock's time_point is referred to as the clock's [*epoch*](#def:epoch "30.3Cpp17Clock requirements[time.clock.req]")[.](#1.sentence-2)
A clock shall meet the requirements in Table [131](#tab:time.clock "Table 131: Cpp17Clock requirements")[.](#1.sentence-3)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L982)
In Table [131](#tab:time.clock "Table 131: Cpp17Clock requirements") C1 and C2 denote clock types[.](#2.sentence-1)
t1 andt2 are values returned by C1::now() where the call returning t1 happens
before ([[intro.multithread]](intro.multithread "6.10.2Multi-threaded executions and data races")) the call returning t2 and both of these calls
occur
before C1::time_point::max()[.](#2.sentence-2)
[*Note [1](#note-1)*:
This means C1 did not wrap around between t1 andt2[.](#2.sentence-3)
— *end note*]
Table [131](#tab:time.clock) — *Cpp17Clock* requirements [[tab:time.clock]](./tab:time.clock)
| [🔗](#tab:time.clock-row-1)<br>**Expression** | **Return type** | **Operational semantics** |
| --- | --- | --- |
| [🔗](#tab:time.clock-row-2)<br>C1::rep | An arithmetic type or a class emulating an arithmetic type | The representation type of C1::duration[.](#tab:time.clock-row-2-column-3-sentence-1) |
| [🔗](#tab:time.clock-row-3)<br>C1::period | a specialization of ratio | The tick period of the clock in seconds[.](#tab:time.clock-row-3-column-3-sentence-1) |
| [🔗](#tab:time.clock-row-4)<br>C1::duration | chrono::duration<C1::rep, C1::period> | The duration type of the clock[.](#tab:time.clock-row-4-column-3-sentence-1) |
| [🔗](#tab:time.clock-row-5)<br>C1::time_point | chrono::time_point<C1> or chrono::time_point<C2, C1::duration> | The time_point type of the clock[.](#tab:time.clock-row-5-column-3-sentence-1)<br>C1 and C2 shall refer to the same epoch[.](#tab:time.clock-row-5-column-3-sentence-2) |
| [🔗](#tab:time.clock-row-6)<br>C1::is_steady | const bool | true if t1 <= t2 is always true and the time between clock ticks is constant, otherwise false[.](#tab:time.clock-row-6-column-3-sentence-1) |
| [🔗](#tab:time.clock-row-7)<br>C1::now() | C1::time_point | Returns a time_point object representing the current point in time[.](#tab:time.clock-row-7-column-3-sentence-1) |
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L1032)
[*Note [2](#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[.](#3.sentence-1)
— *end note*]
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L1038)
A type TC meets the *Cpp17TrivialClock* requirements if
- [(4.1)](#4.1)
TC meets the [*Cpp17Clock*](#:Cpp17Clock "30.3Cpp17Clock requirements[time.clock.req]") requirements,
- [(4.2)](#4.2)
the types TC::rep, TC::duration, and TC::time_point meet the [*Cpp17EqualityComparable*](utility.arg.requirements#:Cpp17EqualityComparable "16.4.4.2Template argument requirements[utility.arg.requirements]") (Table [28](utility.arg.requirements#tab:cpp17.equalitycomparable "Table 28: Cpp17EqualityComparable requirements")) and[*Cpp17LessThanComparable*](utility.arg.requirements#:Cpp17LessThanComparable "16.4.4.2Template argument requirements[utility.arg.requirements]") (Table [29](utility.arg.requirements#tab:cpp17.lessthancomparable "Table 29: Cpp17LessThanComparable requirements"))
and [*Cpp17Swappable*](swappable.requirements#:Cpp17Swappable "16.4.4.3Swappable requirements[swappable.requirements]") ([[swappable.requirements]](swappable.requirements "16.4.4.3Swappable requirements"))
requirements and the requirements of
numeric types ([[numeric.requirements]](numeric.requirements "29.2Numeric type requirements")),
[*Note [3](#note-3)*:
This means, in particular,
that operations on these types will not throw exceptions[.](#4.2.sentence-1)
— *end note*]
- [(4.3)](#4.3)
the function TC::now() does not throw exceptions, and
- [(4.4)](#4.4)
the type TC::time_point::clock meets the *Cpp17TrivialClock* requirements, recursively[.](#4.sentence-1)