From Jason Turner

[time.traits]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpr57xbhr9/{from.md → to.md} +37 -15
tmp/tmpr57xbhr9/{from.md → to.md} RENAMED
@@ -1,12 +1,11 @@
1
- ### Time-related traits <a id="time.traits">[[time.traits]]</a>
2
 
3
- #### `treat_as_floating_point` <a id="time.traits.is_fp">[[time.traits.is_fp]]</a>
4
 
5
  ``` cpp
6
- 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 `treat_as_floating_point_v<Rep>` is
@@ -19,69 +18,68 @@ 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>
28
  struct duration_values {
29
  public:
30
- static constexpr Rep zero();
31
- static constexpr Rep min();
32
- static constexpr Rep max();
33
  };
34
  ```
35
 
36
  The `duration` template uses the `duration_values` trait to construct
37
- special values of the durations representation (`Rep`). This is done
38
  because the representation might be a class type with behavior which
39
  requires some other implementation to return these special values. In
40
  that case, the author of that class type should specialize
41
  `duration_values` to return the indicated values.
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
 
@@ -101,5 +99,29 @@ struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Cloc
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
104
  `duration`s.
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Time-related traits <a id="time.traits">[[time.traits]]</a>
2
 
3
+ ### `treat_as_floating_point` <a id="time.traits.is.fp">[[time.traits.is.fp]]</a>
4
 
5
  ``` cpp
6
+ template<class Rep> struct treat_as_floating_point : is_floating_point<Rep> { };
 
7
  ```
8
 
9
  The `duration` template uses the `treat_as_floating_point` trait to help
10
  determine if a `duration` object can be converted to another `duration`
11
  with a different tick `period`. If `treat_as_floating_point_v<Rep>` is
 
18
  one value by another with acceptable loss of precision. If
19
  `treat_as_floating_point_v<Rep>` is `false`, `Rep` will be treated as if
20
  it behaved like an integral type for the purpose of these
21
  conversions. — *end note*]
22
 
23
+ ### `duration_values` <a id="time.traits.duration.values">[[time.traits.duration.values]]</a>
24
 
25
  ``` cpp
26
  template<class Rep>
27
  struct duration_values {
28
  public:
29
+ static constexpr Rep zero() noexcept;
30
+ static constexpr Rep min() noexcept;
31
+ static constexpr Rep max() noexcept;
32
  };
33
  ```
34
 
35
  The `duration` template uses the `duration_values` trait to construct
36
+ special values of the duration’s representation (`Rep`). This is done
37
  because the representation might be a class type with behavior which
38
  requires some other implementation to return these special values. In
39
  that case, the author of that class type should specialize
40
  `duration_values` to return the indicated values.
41
 
42
  ``` cpp
43
+ static constexpr Rep zero() noexcept;
44
  ```
45
 
46
  *Returns:* `Rep(0)`.
47
 
48
  [*Note 1*: `Rep(0)` is specified instead of `Rep()` because `Rep()` may
49
  have some other meaning, such as an uninitialized value. — *end note*]
50
 
51
  *Remarks:* The value returned shall be the additive identity.
52
 
53
  ``` cpp
54
+ static constexpr Rep min() noexcept;
55
  ```
56
 
57
  *Returns:* `numeric_limits<Rep>::lowest()`.
58
 
59
  *Remarks:* The value returned shall compare less than or equal to
60
  `zero()`.
61
 
62
  ``` cpp
63
+ static constexpr Rep max() noexcept;
64
  ```
65
 
66
  *Returns:* `numeric_limits<Rep>::max()`.
67
 
68
  *Remarks:* The value returned shall compare greater than `zero()`.
69
 
70
+ ### Specializations of `common_type` <a id="time.traits.specializations">[[time.traits.specializations]]</a>
71
 
72
  ``` cpp
73
  template<class Rep1, class Period1, class Rep2, class Period2>
74
  struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>> {
75
  using type = chrono::duration<common_type_t<Rep1, Rep2>, see below>;
76
  };
77
  ```
78
 
79
  The `period` of the `duration` indicated by this specialization of
80
+ `common_type` is the greatest common divisor of `Period1` and `Period2`.
 
81
 
82
  [*Note 1*: This can be computed by forming a ratio of the greatest
83
  common divisor of `Period1::num` and `Period2::num` and the least common
84
  multiple of `Period1::den` and `Period2::den`. — *end note*]
85
 
 
99
 
100
  The common type of two `time_point` types is a `time_point` with the
101
  same clock as the two types and the common type of their two
102
  `duration`s.
103
 
104
+ ### Class template `is_clock` <a id="time.traits.is.clock">[[time.traits.is.clock]]</a>
105
+
106
+ ``` cpp
107
+ template<class T> struct is_clock;
108
+ ```
109
+
110
+ `is_clock` is a *Cpp17UnaryTypeTrait* [[meta.rqmts]] with a base
111
+ characteristic of `true_type` if `T` meets the *Cpp17Clock* requirements
112
+ [[time.clock.req]], otherwise `false_type`. For the purposes of the
113
+ specification of this trait, the extent to which an implementation
114
+ determines that a type cannot meet the *Cpp17Clock* requirements is
115
+ unspecified, except that as a minimum a type `T` shall not qualify as a
116
+ *Cpp17Clock* unless it meets all of the following conditions:
117
+
118
+ - the *qualified-id*s `T::rep`, `T::period`, `T::duration`, and
119
+ `T::time_point` are valid and each denotes a type [[temp.deduct]],
120
+ - the expression `T::is_steady` is well-formed when treated as an
121
+ unevaluated operand,
122
+ - the expression `T::now()` is well-formed when treated as an
123
+ unevaluated operand.
124
+
125
+ The behavior of a program that adds specializations for `is_clock` is
126
+ undefined.
127
+