tmp/tmp_il2ws3r/{from.md → to.md}
RENAMED
|
@@ -7,19 +7,21 @@ template <class Rep> struct treat_as_floating_point
|
|
| 7 |
: is_floating_point<Rep> { };
|
| 8 |
```
|
| 9 |
|
| 10 |
The `duration` template uses the `treat_as_floating_point` trait to help
|
| 11 |
determine if a `duration` object can be converted to another `duration`
|
| 12 |
-
with a different tick `period`. If `
|
| 13 |
-
|
| 14 |
Otherwise, the implicit convertibility depends on the tick `period`s of
|
| 15 |
-
the `duration`s.
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
|
| 22 |
#### `duration_values` <a id="time.traits.duration_values">[[time.traits.duration_values]]</a>
|
| 23 |
|
| 24 |
``` cpp
|
| 25 |
template <class Rep>
|
|
@@ -40,57 +42,62 @@ that case, the author of that class type should specialize
|
|
| 40 |
|
| 41 |
``` cpp
|
| 42 |
static constexpr Rep zero();
|
| 43 |
```
|
| 44 |
|
| 45 |
-
*Returns:* `Rep(0)`.
|
| 46 |
-
`Rep()` may have some other meaning, such as an uninitialized value.
|
| 47 |
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
``` cpp
|
| 51 |
static constexpr Rep min();
|
| 52 |
```
|
| 53 |
|
| 54 |
*Returns:* `numeric_limits<Rep>::lowest()`.
|
| 55 |
|
| 56 |
-
The value returned shall compare less than or equal to
|
|
|
|
| 57 |
|
| 58 |
``` cpp
|
| 59 |
static constexpr Rep max();
|
| 60 |
```
|
| 61 |
|
| 62 |
*Returns:* `numeric_limits<Rep>::max()`.
|
| 63 |
|
| 64 |
-
The value returned shall compare greater than `zero()`.
|
| 65 |
|
| 66 |
#### Specializations of `common_type` <a id="time.traits.specializations">[[time.traits.specializations]]</a>
|
| 67 |
|
| 68 |
``` cpp
|
| 69 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 70 |
struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>> {
|
| 71 |
-
|
| 72 |
};
|
| 73 |
```
|
| 74 |
|
| 75 |
The `period` of the `duration` indicated by this specialization of
|
| 76 |
`common_type` shall be the greatest common divisor of `Period1` and
|
| 77 |
-
`Period2`.
|
|
|
|
|
|
|
| 78 |
common divisor of `Period1::num` and `Period2::num` and the least common
|
| 79 |
-
multiple of `Period1::den` and `Period2::den`.
|
| 80 |
|
| 81 |
-
The `typedef` name `type` is a synonym for the `duration`
|
| 82 |
-
largest tick `period` possible where both `duration` arguments
|
| 83 |
-
convert to it without requiring a division operation. The
|
| 84 |
-
of this type is intended to be able to hold any value
|
| 85 |
-
this conversion with no truncation error, although
|
| 86 |
-
durations may have round-off errors.
|
| 87 |
|
| 88 |
``` cpp
|
| 89 |
template <class Clock, class Duration1, class Duration2>
|
| 90 |
struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>> {
|
| 91 |
-
|
| 92 |
};
|
| 93 |
```
|
| 94 |
|
| 95 |
The common type of two `time_point` types is a `time_point` with the
|
| 96 |
same clock as the two types and the common type of their two
|
|
|
|
| 7 |
: is_floating_point<Rep> { };
|
| 8 |
```
|
| 9 |
|
| 10 |
The `duration` template uses the `treat_as_floating_point` trait to help
|
| 11 |
determine if a `duration` object can be converted to another `duration`
|
| 12 |
+
with a different tick `period`. If `treat_as_floating_point_v<Rep>` is
|
| 13 |
+
`true`, then implicit conversions are allowed among `duration`s.
|
| 14 |
Otherwise, the implicit convertibility depends on the tick `period`s of
|
| 15 |
+
the `duration`s.
|
| 16 |
+
|
| 17 |
+
[*Note 1*: The intention of this trait is to indicate whether a given
|
| 18 |
+
class behaves like a floating-point type, and thus allows division of
|
| 19 |
+
one value by another with acceptable loss of precision. If
|
| 20 |
+
`treat_as_floating_point_v<Rep>` is `false`, `Rep` will be treated as if
|
| 21 |
+
it behaved like an integral type for the purpose of these
|
| 22 |
+
conversions. — *end note*]
|
| 23 |
|
| 24 |
#### `duration_values` <a id="time.traits.duration_values">[[time.traits.duration_values]]</a>
|
| 25 |
|
| 26 |
``` cpp
|
| 27 |
template <class Rep>
|
|
|
|
| 42 |
|
| 43 |
``` cpp
|
| 44 |
static constexpr Rep zero();
|
| 45 |
```
|
| 46 |
|
| 47 |
+
*Returns:* `Rep(0)`.
|
|
|
|
| 48 |
|
| 49 |
+
[*Note 1*: `Rep(0)` is specified instead of `Rep()` because `Rep()` may
|
| 50 |
+
have some other meaning, such as an uninitialized value. — *end note*]
|
| 51 |
+
|
| 52 |
+
*Remarks:* The value returned shall be the additive identity.
|
| 53 |
|
| 54 |
``` cpp
|
| 55 |
static constexpr Rep min();
|
| 56 |
```
|
| 57 |
|
| 58 |
*Returns:* `numeric_limits<Rep>::lowest()`.
|
| 59 |
|
| 60 |
+
*Remarks:* The value returned shall compare less than or equal to
|
| 61 |
+
`zero()`.
|
| 62 |
|
| 63 |
``` cpp
|
| 64 |
static constexpr Rep max();
|
| 65 |
```
|
| 66 |
|
| 67 |
*Returns:* `numeric_limits<Rep>::max()`.
|
| 68 |
|
| 69 |
+
*Remarks:* The value returned shall compare greater than `zero()`.
|
| 70 |
|
| 71 |
#### Specializations of `common_type` <a id="time.traits.specializations">[[time.traits.specializations]]</a>
|
| 72 |
|
| 73 |
``` cpp
|
| 74 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 75 |
struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>> {
|
| 76 |
+
using type = chrono::duration<common_type_t<Rep1, Rep2>, see below>;
|
| 77 |
};
|
| 78 |
```
|
| 79 |
|
| 80 |
The `period` of the `duration` indicated by this specialization of
|
| 81 |
`common_type` shall be the greatest common divisor of `Period1` and
|
| 82 |
+
`Period2`.
|
| 83 |
+
|
| 84 |
+
[*Note 1*: This can be computed by forming a ratio of the greatest
|
| 85 |
common divisor of `Period1::num` and `Period2::num` and the least common
|
| 86 |
+
multiple of `Period1::den` and `Period2::den`. — *end note*]
|
| 87 |
|
| 88 |
+
[*Note 2*: The `typedef` name `type` is a synonym for the `duration`
|
| 89 |
+
with the largest tick `period` possible where both `duration` arguments
|
| 90 |
+
will convert to it without requiring a division operation. The
|
| 91 |
+
representation of this type is intended to be able to hold any value
|
| 92 |
+
resulting from this conversion with no truncation error, although
|
| 93 |
+
floating-point durations may have round-off errors. — *end note*]
|
| 94 |
|
| 95 |
``` cpp
|
| 96 |
template <class Clock, class Duration1, class Duration2>
|
| 97 |
struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>> {
|
| 98 |
+
using type = chrono::time_point<Clock, common_type_t<Duration1, Duration2>>;
|
| 99 |
};
|
| 100 |
```
|
| 101 |
|
| 102 |
The common type of two `time_point` types is a `time_point` with the
|
| 103 |
same clock as the two types and the common type of their two
|