From Jason Turner

[time.point]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpq7dgqmlx/{from.md → to.md} +86 -60
tmp/tmpq7dgqmlx/{from.md → to.md} RENAMED
@@ -1,15 +1,17 @@
1
- ### Class template `time_point` <a id="time.point">[[time.point]]</a>
2
 
3
  ``` cpp
 
4
  template<class Clock, class Duration = typename Clock::duration>
5
  class time_point {
6
  public:
7
  using clock = Clock;
8
  using duration = Duration;
9
  using rep = typename duration::rep;
10
  using period = typename duration::period;
 
11
  private:
12
  duration d_; // exposition only
13
 
14
  public:
15
  // [time.point.cons], construct
@@ -20,102 +22,133 @@ public:
20
 
21
  // [time.point.observer], observer
22
  constexpr duration time_since_epoch() const;
23
 
24
  // [time.point.arithmetic], arithmetic
 
 
 
 
25
  constexpr time_point& operator+=(const duration& d);
26
  constexpr time_point& operator-=(const duration& d);
27
 
28
  // [time.point.special], special values
29
- static constexpr time_point min();
30
- static constexpr time_point max();
31
  };
 
32
  ```
33
 
34
- `Clock` shall meet the Clock requirements ([[time.clock.req]]).
 
35
 
36
  If `Duration` is not an instance of `duration`, the program is
37
  ill-formed.
38
 
39
- #### `time_point` constructors <a id="time.point.cons">[[time.point.cons]]</a>
40
 
41
  ``` cpp
42
  constexpr time_point();
43
  ```
44
 
45
- *Effects:* Constructs an object of type `time_point`, initializing `d_`
46
- with `duration::zero()`. Such a `time_point` object represents the
47
- epoch.
48
 
49
  ``` cpp
50
  constexpr explicit time_point(const duration& d);
51
  ```
52
 
53
- *Effects:* Constructs an object of type `time_point`, initializing `d_`
54
- with `d`. Such a `time_point` object represents the epoch `+ d`.
55
 
56
  ``` cpp
57
  template<class Duration2>
58
  constexpr time_point(const time_point<clock, Duration2>& t);
59
  ```
60
 
61
- *Remarks:* This constructor shall not participate in overload resolution
62
- unless `Duration2` is implicitly convertible to `duration`.
63
 
64
- *Effects:* Constructs an object of type `time_point`, initializing `d_`
65
- with `t.time_since_epoch()`.
66
 
67
- #### `time_point` observer <a id="time.point.observer">[[time.point.observer]]</a>
68
 
69
  ``` cpp
70
  constexpr duration time_since_epoch() const;
71
  ```
72
 
73
  *Returns:* `d_`.
74
 
75
- #### `time_point` arithmetic <a id="time.point.arithmetic">[[time.point.arithmetic]]</a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
 
77
  ``` cpp
78
  constexpr time_point& operator+=(const duration& d);
79
  ```
80
 
81
- *Effects:* As if by: `d_ += d;`
82
 
83
  *Returns:* `*this`.
84
 
85
  ``` cpp
86
  constexpr time_point& operator-=(const duration& d);
87
  ```
88
 
89
- *Effects:* As if by: `d_ -= d;`
90
 
91
  *Returns:* `*this`.
92
 
93
- #### `time_point` special values <a id="time.point.special">[[time.point.special]]</a>
94
 
95
  ``` cpp
96
- static constexpr time_point min();
97
  ```
98
 
99
  *Returns:* `time_point(duration::min())`.
100
 
101
  ``` cpp
102
- static constexpr time_point max();
103
  ```
104
 
105
  *Returns:* `time_point(duration::max())`.
106
 
107
- #### `time_point` non-member arithmetic <a id="time.point.nonmember">[[time.point.nonmember]]</a>
108
 
109
  ``` cpp
110
  template<class Clock, class Duration1, class Rep2, class Period2>
111
  constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
112
  operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
113
  ```
114
 
115
- *Returns:* *`CT`*`(lhs.time_since_epoch() + rhs)`, where *`CT`* is the
116
- type of the return value.
117
 
118
  ``` cpp
119
  template<class Rep1, class Period1, class Clock, class Duration2>
120
  constexpr time_point<Clock, common_type_t<duration<Rep1, Period1>, Duration2>>
121
  operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
@@ -127,120 +160,113 @@ template <class Rep1, class Period1, class Clock, class Duration2>
127
  template<class Clock, class Duration1, class Rep2, class Period2>
128
  constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
129
  operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
130
  ```
131
 
132
- *Returns:* *`CT`*`(lhs.time_since_epoch() - rhs)`, where *`CT`* is the
133
- type of the return value.
134
 
135
  ``` cpp
136
  template<class Clock, class Duration1, class Duration2>
137
  constexpr common_type_t<Duration1, Duration2>
138
  operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
139
  ```
140
 
141
  *Returns:* `lhs.time_since_epoch() - rhs.time_since_epoch()`.
142
 
143
- #### `time_point` comparisons <a id="time.point.comparisons">[[time.point.comparisons]]</a>
144
 
145
  ``` cpp
146
  template<class Clock, class Duration1, class Duration2>
147
  constexpr bool operator==(const time_point<Clock, Duration1>& lhs,
148
  const time_point<Clock, Duration2>& rhs);
149
  ```
150
 
151
  *Returns:* `lhs.time_since_epoch() == rhs.time_since_epoch()`.
152
 
153
- ``` cpp
154
- template <class Clock, class Duration1, class Duration2>
155
- constexpr bool operator!=(const time_point<Clock, Duration1>& lhs,
156
- const time_point<Clock, Duration2>& rhs);
157
- ```
158
-
159
- *Returns:* `!(lhs == rhs)`.
160
-
161
  ``` cpp
162
  template<class Clock, class Duration1, class Duration2>
163
  constexpr bool operator<(const time_point<Clock, Duration1>& lhs,
164
  const time_point<Clock, Duration2>& rhs);
165
  ```
166
 
167
  *Returns:* `lhs.time_since_epoch() < rhs.time_since_epoch()`.
168
 
169
- ``` cpp
170
- template <class Clock, class Duration1, class Duration2>
171
- constexpr bool operator<=(const time_point<Clock, Duration1>& lhs,
172
- const time_point<Clock, Duration2>& rhs);
173
- ```
174
-
175
- *Returns:* `!(rhs < lhs)`.
176
-
177
  ``` cpp
178
  template<class Clock, class Duration1, class Duration2>
179
  constexpr bool operator>(const time_point<Clock, Duration1>& lhs,
180
  const time_point<Clock, Duration2>& rhs);
181
  ```
182
 
183
  *Returns:* `rhs < lhs`.
184
 
 
 
 
 
 
 
 
 
185
  ``` cpp
186
  template<class Clock, class Duration1, class Duration2>
187
  constexpr bool operator>=(const time_point<Clock, Duration1>& lhs,
188
  const time_point<Clock, Duration2>& rhs);
189
  ```
190
 
191
  *Returns:* `!(lhs < rhs)`.
192
 
193
- #### `time_point_cast` <a id="time.point.cast">[[time.point.cast]]</a>
 
 
 
 
 
 
 
 
 
194
 
195
  ``` cpp
196
  template<class ToDuration, class Clock, class Duration>
197
- constexpr time_point<Clock, ToDuration>
198
- time_point_cast(const time_point<Clock, Duration>& t);
199
  ```
200
 
201
- *Remarks:* This function shall not participate in overload resolution
202
- unless `ToDuration` is a specialization of `duration`.
203
 
204
  *Returns:*
205
 
206
  ``` cpp
207
  time_point<Clock, ToDuration>(duration_cast<ToDuration>(t.time_since_epoch()))
208
  ```
209
 
210
  ``` cpp
211
  template<class ToDuration, class Clock, class Duration>
212
- constexpr time_point<Clock, ToDuration>
213
- floor(const time_point<Clock, Duration>& tp);
214
  ```
215
 
216
- *Remarks:* This function shall not participate in overload resolution
217
- unless `ToDuration` is a specialization of `duration`.
218
 
219
  *Returns:*
220
  `time_point<Clock, ToDuration>(floor<ToDuration>(tp.time_since_epoch()))`.
221
 
222
  ``` cpp
223
  template<class ToDuration, class Clock, class Duration>
224
- constexpr time_point<Clock, ToDuration>
225
- ceil(const time_point<Clock, Duration>& tp);
226
  ```
227
 
228
- *Remarks:* This function shall not participate in overload resolution
229
- unless `ToDuration` is a specialization of `duration`.
230
 
231
  *Returns:*
232
  `time_point<Clock, ToDuration>(ceil<ToDuration>(tp.time_since_epoch()))`.
233
 
234
  ``` cpp
235
  template<class ToDuration, class Clock, class Duration>
236
- constexpr time_point<Clock, ToDuration>
237
- round(const time_point<Clock, Duration>& tp);
238
  ```
239
 
240
- *Remarks:* This function shall not participate in overload resolution
241
- unless `ToDuration` is a specialization of `duration`, and
242
  `treat_as_floating_point_v<typename ToDuration::rep>` is `false`.
243
 
244
  *Returns:*
245
  `time_point<Clock, ToDuration>(round<ToDuration>(tp.time_since_epoch()))`.
246
 
 
1
+ ## Class template `time_point` <a id="time.point">[[time.point]]</a>
2
 
3
  ``` cpp
4
+ namespace std::chrono {
5
  template<class Clock, class Duration = typename Clock::duration>
6
  class time_point {
7
  public:
8
  using clock = Clock;
9
  using duration = Duration;
10
  using rep = typename duration::rep;
11
  using period = typename duration::period;
12
+
13
  private:
14
  duration d_; // exposition only
15
 
16
  public:
17
  // [time.point.cons], construct
 
22
 
23
  // [time.point.observer], observer
24
  constexpr duration time_since_epoch() const;
25
 
26
  // [time.point.arithmetic], arithmetic
27
+ constexpr time_point& operator++();
28
+ constexpr time_point operator++(int);
29
+ constexpr time_point& operator--();
30
+ constexpr time_point operator--(int);
31
  constexpr time_point& operator+=(const duration& d);
32
  constexpr time_point& operator-=(const duration& d);
33
 
34
  // [time.point.special], special values
35
+ static constexpr time_point min() noexcept;
36
+ static constexpr time_point max() noexcept;
37
  };
38
+ }
39
  ```
40
 
41
+ `Clock` shall either meet the *Cpp17Clock* requirements
42
+ [[time.clock.req]] or be the type `local_t`.
43
 
44
  If `Duration` is not an instance of `duration`, the program is
45
  ill-formed.
46
 
47
+ ### Constructors <a id="time.point.cons">[[time.point.cons]]</a>
48
 
49
  ``` cpp
50
  constexpr time_point();
51
  ```
52
 
53
+ *Effects:* Initializes `d_` with `duration::zero()`. Such a `time_point`
54
+ object represents the epoch.
 
55
 
56
  ``` cpp
57
  constexpr explicit time_point(const duration& d);
58
  ```
59
 
60
+ *Effects:* Initializes `d_` with `d`. Such a `time_point` object
61
+ represents the epoch `+ d`.
62
 
63
  ``` cpp
64
  template<class Duration2>
65
  constexpr time_point(const time_point<clock, Duration2>& t);
66
  ```
67
 
68
+ *Constraints:* `is_convertible_v<Duration2, duration>` is `true`.
 
69
 
70
+ *Effects:* Initializes `d_` with `t.time_since_epoch()`.
 
71
 
72
+ ### Observer <a id="time.point.observer">[[time.point.observer]]</a>
73
 
74
  ``` cpp
75
  constexpr duration time_since_epoch() const;
76
  ```
77
 
78
  *Returns:* `d_`.
79
 
80
+ ### Arithmetic <a id="time.point.arithmetic">[[time.point.arithmetic]]</a>
81
+
82
+ ``` cpp
83
+ constexpr time_point& operator++();
84
+ ```
85
+
86
+ *Effects:* Equivalent to: `++d_`.
87
+
88
+ *Returns:* `*this`.
89
+
90
+ ``` cpp
91
+ constexpr time_point operator++(int);
92
+ ```
93
+
94
+ *Effects:* Equivalent to: `return time_point{d_++};`
95
+
96
+ ``` cpp
97
+ constexpr time_point& operator--();
98
+ ```
99
+
100
+ *Effects:* Equivalent to: `–d_`.
101
+
102
+ *Returns:* `*this`.
103
+
104
+ ``` cpp
105
+ constexpr time_point operator--(int);
106
+ ```
107
+
108
+ *Effects:* Equivalent to: `return time_point{d_--};`
109
 
110
  ``` cpp
111
  constexpr time_point& operator+=(const duration& d);
112
  ```
113
 
114
+ *Effects:* Equivalent to: `d_ += d`.
115
 
116
  *Returns:* `*this`.
117
 
118
  ``` cpp
119
  constexpr time_point& operator-=(const duration& d);
120
  ```
121
 
122
+ *Effects:* Equivalent to: `d_ -= d`.
123
 
124
  *Returns:* `*this`.
125
 
126
+ ### Special values <a id="time.point.special">[[time.point.special]]</a>
127
 
128
  ``` cpp
129
+ static constexpr time_point min() noexcept;
130
  ```
131
 
132
  *Returns:* `time_point(duration::min())`.
133
 
134
  ``` cpp
135
+ static constexpr time_point max() noexcept;
136
  ```
137
 
138
  *Returns:* `time_point(duration::max())`.
139
 
140
+ ### Non-member arithmetic <a id="time.point.nonmember">[[time.point.nonmember]]</a>
141
 
142
  ``` cpp
143
  template<class Clock, class Duration1, class Rep2, class Period2>
144
  constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
145
  operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
146
  ```
147
 
148
+ *Returns:* `CT(lhs.time_since_epoch() + rhs)`, where `CT` is the type of
149
+ the return value.
150
 
151
  ``` cpp
152
  template<class Rep1, class Period1, class Clock, class Duration2>
153
  constexpr time_point<Clock, common_type_t<duration<Rep1, Period1>, Duration2>>
154
  operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
 
160
  template<class Clock, class Duration1, class Rep2, class Period2>
161
  constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
162
  operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
163
  ```
164
 
165
+ *Returns:* `CT(lhs.time_since_epoch() - rhs)`, where `CT` is the type of
166
+ the return value.
167
 
168
  ``` cpp
169
  template<class Clock, class Duration1, class Duration2>
170
  constexpr common_type_t<Duration1, Duration2>
171
  operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
172
  ```
173
 
174
  *Returns:* `lhs.time_since_epoch() - rhs.time_since_epoch()`.
175
 
176
+ ### Comparisons <a id="time.point.comparisons">[[time.point.comparisons]]</a>
177
 
178
  ``` cpp
179
  template<class Clock, class Duration1, class Duration2>
180
  constexpr bool operator==(const time_point<Clock, Duration1>& lhs,
181
  const time_point<Clock, Duration2>& rhs);
182
  ```
183
 
184
  *Returns:* `lhs.time_since_epoch() == rhs.time_since_epoch()`.
185
 
 
 
 
 
 
 
 
 
186
  ``` cpp
187
  template<class Clock, class Duration1, class Duration2>
188
  constexpr bool operator<(const time_point<Clock, Duration1>& lhs,
189
  const time_point<Clock, Duration2>& rhs);
190
  ```
191
 
192
  *Returns:* `lhs.time_since_epoch() < rhs.time_since_epoch()`.
193
 
 
 
 
 
 
 
 
 
194
  ``` cpp
195
  template<class Clock, class Duration1, class Duration2>
196
  constexpr bool operator>(const time_point<Clock, Duration1>& lhs,
197
  const time_point<Clock, Duration2>& rhs);
198
  ```
199
 
200
  *Returns:* `rhs < lhs`.
201
 
202
+ ``` cpp
203
+ template<class Clock, class Duration1, class Duration2>
204
+ constexpr bool operator<=(const time_point<Clock, Duration1>& lhs,
205
+ const time_point<Clock, Duration2>& rhs);
206
+ ```
207
+
208
+ *Returns:* `!(rhs < lhs)`.
209
+
210
  ``` cpp
211
  template<class Clock, class Duration1, class Duration2>
212
  constexpr bool operator>=(const time_point<Clock, Duration1>& lhs,
213
  const time_point<Clock, Duration2>& rhs);
214
  ```
215
 
216
  *Returns:* `!(lhs < rhs)`.
217
 
218
+ ``` cpp
219
+ template<class Clock, class Duration1,
220
+ three_way_comparable_with<Duration1> Duration2>
221
+ constexpr auto operator<=>(const time_point<Clock, Duration1>& lhs,
222
+ const time_point<Clock, Duration2>& rhs);
223
+ ```
224
+
225
+ *Returns:* `lhs.time_since_epoch() <=> rhs.time_since_epoch()`.
226
+
227
+ ### Conversions <a id="time.point.cast">[[time.point.cast]]</a>
228
 
229
  ``` cpp
230
  template<class ToDuration, class Clock, class Duration>
231
+ constexpr time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t);
 
232
  ```
233
 
234
+ *Constraints:* `ToDuration` is a specialization of `duration`.
 
235
 
236
  *Returns:*
237
 
238
  ``` cpp
239
  time_point<Clock, ToDuration>(duration_cast<ToDuration>(t.time_since_epoch()))
240
  ```
241
 
242
  ``` cpp
243
  template<class ToDuration, class Clock, class Duration>
244
+ constexpr time_point<Clock, ToDuration> floor(const time_point<Clock, Duration>& tp);
 
245
  ```
246
 
247
+ *Constraints:* `ToDuration` is a specialization of `duration`.
 
248
 
249
  *Returns:*
250
  `time_point<Clock, ToDuration>(floor<ToDuration>(tp.time_since_epoch()))`.
251
 
252
  ``` cpp
253
  template<class ToDuration, class Clock, class Duration>
254
+ constexpr time_point<Clock, ToDuration> ceil(const time_point<Clock, Duration>& tp);
 
255
  ```
256
 
257
+ *Constraints:* `ToDuration` is a specialization of `duration`.
 
258
 
259
  *Returns:*
260
  `time_point<Clock, ToDuration>(ceil<ToDuration>(tp.time_since_epoch()))`.
261
 
262
  ``` cpp
263
  template<class ToDuration, class Clock, class Duration>
264
+ constexpr time_point<Clock, ToDuration> round(const time_point<Clock, Duration>& tp);
 
265
  ```
266
 
267
+ *Constraints:* `ToDuration` is a specialization of `duration`, and
 
268
  `treat_as_floating_point_v<typename ToDuration::rep>` is `false`.
269
 
270
  *Returns:*
271
  `time_point<Clock, ToDuration>(round<ToDuration>(tp.time_since_epoch()))`.
272