tmp/tmpd1nr2ljt/{from.md → to.md}
RENAMED
|
@@ -6,41 +6,51 @@ template <class Rep2>
|
|
| 6 |
```
|
| 7 |
|
| 8 |
*Remarks:* This constructor shall not participate in overload resolution
|
| 9 |
unless `Rep2` is implicitly convertible to `rep` and
|
| 10 |
|
| 11 |
-
- `
|
| 12 |
-
- `
|
|
|
|
|
|
|
| 13 |
|
| 14 |
``` cpp
|
| 15 |
duration<int, milli> d(3); // OK
|
| 16 |
duration<int, milli> d(3.5); // error
|
| 17 |
```
|
| 18 |
|
|
|
|
|
|
|
| 19 |
*Effects:* Constructs an object of type `duration`.
|
| 20 |
|
| 21 |
-
`count() == static_cast<rep>(r)`.
|
| 22 |
|
| 23 |
``` cpp
|
| 24 |
template <class Rep2, class Period2>
|
| 25 |
constexpr duration(const duration<Rep2, Period2>& d);
|
| 26 |
```
|
| 27 |
|
| 28 |
*Remarks:* This constructor shall not participate in overload resolution
|
| 29 |
unless no overflow is induced in the conversion and
|
| 30 |
-
`
|
| 31 |
`ratio_divide<Period2, period>::den` is `1` and
|
| 32 |
-
`
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
``` cpp
|
| 38 |
duration<int, milli> ms(3);
|
| 39 |
duration<int, micro> us = ms; // OK
|
| 40 |
duration<int, milli> ms2 = us; // error
|
| 41 |
```
|
| 42 |
|
|
|
|
|
|
|
| 43 |
*Effects:* Constructs an object of type `duration`, constructing `rep_`
|
| 44 |
from
|
| 45 |
`duration_cast<duration>(d).count()`.
|
| 46 |
|
|
|
|
| 6 |
```
|
| 7 |
|
| 8 |
*Remarks:* This constructor shall not participate in overload resolution
|
| 9 |
unless `Rep2` is implicitly convertible to `rep` and
|
| 10 |
|
| 11 |
+
- `treat_as_floating_point_v<rep>` is `true` or
|
| 12 |
+
- `treat_as_floating_point_v<Rep2>` is `false`.
|
| 13 |
+
|
| 14 |
+
[*Example 1*:
|
| 15 |
|
| 16 |
``` cpp
|
| 17 |
duration<int, milli> d(3); // OK
|
| 18 |
duration<int, milli> d(3.5); // error
|
| 19 |
```
|
| 20 |
|
| 21 |
+
— *end example*]
|
| 22 |
+
|
| 23 |
*Effects:* Constructs an object of type `duration`.
|
| 24 |
|
| 25 |
+
*Postconditions:* `count() == static_cast<rep>(r)`.
|
| 26 |
|
| 27 |
``` cpp
|
| 28 |
template <class Rep2, class Period2>
|
| 29 |
constexpr duration(const duration<Rep2, Period2>& d);
|
| 30 |
```
|
| 31 |
|
| 32 |
*Remarks:* This constructor shall not participate in overload resolution
|
| 33 |
unless no overflow is induced in the conversion and
|
| 34 |
+
`treat_as_floating_point_v<rep>` is `true` or both
|
| 35 |
`ratio_divide<Period2, period>::den` is `1` and
|
| 36 |
+
`treat_as_floating_point_v<Rep2>` is `false`.
|
| 37 |
+
|
| 38 |
+
[*Note 1*: This requirement prevents implicit truncation error when
|
| 39 |
+
converting between integral-based `duration` types. Such a construction
|
| 40 |
+
could easily lead to confusion about the value of the
|
| 41 |
+
`duration`. — *end note*]
|
| 42 |
+
|
| 43 |
+
[*Example 2*:
|
| 44 |
|
| 45 |
``` cpp
|
| 46 |
duration<int, milli> ms(3);
|
| 47 |
duration<int, micro> us = ms; // OK
|
| 48 |
duration<int, milli> ms2 = us; // error
|
| 49 |
```
|
| 50 |
|
| 51 |
+
— *end example*]
|
| 52 |
+
|
| 53 |
*Effects:* Constructs an object of type `duration`, constructing `rep_`
|
| 54 |
from
|
| 55 |
`duration_cast<duration>(d).count()`.
|
| 56 |
|