From Jason Turner

[meta.trans]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpl91ihvl1/{from.md → to.md} +29 -52
tmp/tmpl91ihvl1/{from.md → to.md} RENAMED
@@ -1,32 +1,23 @@
1
  ### Transformations between types <a id="meta.trans">[[meta.trans]]</a>
2
 
3
- This subclause contains templates that may be used to transform one type
4
- to another following some predefined rule.
5
 
6
- Each of the templates in this subclause shall be a
 
 
 
7
  *Cpp17TransformationTrait* [[meta.rqmts]].
8
 
9
  #### Const-volatile modifications <a id="meta.trans.cv">[[meta.trans.cv]]</a>
10
 
11
- [*Example 1*: `remove_const_t<const volatile int>` evaluates to
12
- `volatile int`, whereas `remove_const_t<const int*>` evaluates to
13
- `const int*`. — *end example*]
14
-
15
  #### Reference modifications <a id="meta.trans.ref">[[meta.trans.ref]]</a>
16
 
17
- [*Note 1*: This rule reflects the semantics of reference collapsing
18
- [[dcl.ref]]. — *end note*]
19
-
20
  #### Sign modifications <a id="meta.trans.sign">[[meta.trans.sign]]</a>
21
 
22
  #### Array modifications <a id="meta.trans.arr">[[meta.trans.arr]]</a>
23
 
24
- [*Note 1*: For multidimensional arrays, only the first array dimension
25
- is removed. For a type “array of `const U`”, the resulting type is
26
- `const U`. — *end note*]
27
-
28
  [*Example 1*:
29
 
30
  ``` cpp
31
  // the following assertions hold:
32
  assert((is_same_v<remove_extent_t<int>, int>));
@@ -51,30 +42,15 @@ assert((is_same_v<remove_all_extents_t<int[][3]>, int>));
51
 
52
  #### Pointer modifications <a id="meta.trans.ptr">[[meta.trans.ptr]]</a>
53
 
54
  #### Other transformations <a id="meta.trans.other">[[meta.trans.other]]</a>
55
 
56
- [*Note 1*: This behavior is similar to the lvalue-to-rvalue
57
- [[conv.lval]], array-to-pointer [[conv.array]], and function-to-pointer
58
- [[conv.func]] conversions applied when an lvalue is used as an rvalue,
59
- but also strips cv-qualifiers from class types in order to more closely
60
- model by-value argument passing. — *end note*]
61
-
62
- [*Note 2*:
63
-
64
- A typical implementation would define `aligned_storage` as:
65
-
66
- ``` cpp
67
- template<size_t Len, size_t Alignment>
68
- struct aligned_storage {
69
- typedef struct {
70
- alignas(Alignment) unsigned char __data[Len];
71
- } type;
72
- };
73
- ```
74
-
75
- — *end note*]
76
 
77
  In addition to being available via inclusion of the `<type_traits>`
78
  header, the templates `unwrap_reference`, `unwrap_ref_decay`,
79
  `unwrap_reference_t`, and `unwrap_ref_decay_t` are available when the
80
  header `<functional>` [[functional.syn]] is included.
@@ -125,11 +101,11 @@ as follows:
125
  `T` be denoted by `T1` and `T2`, respectively, and let `D1` and `D2`
126
  denote the same types as `decay_t<T1>` and `decay_t<T2>`,
127
  respectively.
128
  - If `is_same_v<T1, D1>` is `false` or `is_same_v<T2, D2>` is `false`,
129
  let `C` denote the same type, if any, as `common_type_t<D1, D2>`.
130
- - \[*Note 3*: None of the following will apply if there is a
131
  specialization `common_type<D1, D2>`. — *end note*]
132
  - Otherwise, if
133
  ``` cpp
134
  decay_t<decltype(false ? declval<D1>() : declval<D2>())>
135
  ```
@@ -153,20 +129,19 @@ Note B: Notwithstanding the provisions of [[meta.type.synop]], and
153
  pursuant to [[namespace.std]], a program may specialize
154
  `common_type<T1, T2>` for types `T1` and `T2` such that
155
  `is_same_v<T1, decay_t<T1>>` and `is_same_v<T2, decay_t<T2>>` are each
156
  `true`.
157
 
158
- [*Note 4*: Such specializations are needed when only explicit
159
  conversions are desired between the template arguments. — *end note*]
160
 
161
  Such a specialization need not have a member named `type`, but if it
162
- does, that member shall be a *typedef-name* for an accessible and
163
- unambiguous cv-unqualified non-reference type `C` to which each of the
164
- types `T1` and `T2` is explicitly convertible. Moreover,
165
- `common_type_t<T1, T2>` shall denote the same type, if any, as does
166
- `common_type_t<T2, T1>`. No diagnostic is required for a violation of
167
- this Note’s rules.
168
 
169
  Note C: For the `common_reference` trait applied to a parameter pack `T`
170
  of types, the member `type` shall be either defined or not present as
171
  follows:
172
 
@@ -174,12 +149,14 @@ follows:
174
  - Otherwise, if `sizeof...(T)` is one, let `T0` denote the sole type in
175
  the pack `T`. The member typedef `type` shall denote the same type as
176
  `T0`.
177
  - Otherwise, if `sizeof...(T)` is two, let `T1` and `T2` denote the two
178
  types in the pack `T`. Then
179
- - If `T1` and `T2` are reference types and `COMMON-REF(T1, T2)` is
180
- well-formed, then the member typedef `type` denotes that type.
 
 
181
  - Otherwise, if
182
  `basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>,
183
  {}XREF({}T1), XREF(T2)>::type` is well-formed, then the member
184
  typedef `type` denotes that type.
185
  - Otherwise, if `COND-RES(T1, T2)` is well-formed, then the member
@@ -196,23 +173,23 @@ follows:
196
  - Otherwise, there shall be no member `type`.
197
 
198
  Note D: Notwithstanding the provisions of [[meta.type.synop]], and
199
  pursuant to [[namespace.std]], a program may partially specialize
200
  `basic_common_reference<T, U, TQual, UQual>` for types `T` and `U` such
201
- that `is_same_v<T, decay_t<T>{>}` and `is_same_v<U, decay_t<U>{>}` are
202
- each `true`.
203
 
204
- [*Note 5*: Such specializations can be used to influence the result of
205
  `common_reference`, and are needed when only explicit conversions are
206
  desired between the template arguments. — *end note*]
207
 
208
  Such a specialization need not have a member named `type`, but if it
209
- does, that member shall be a *typedef-name* for an accessible and
210
- unambiguous type `C` to which each of the types `TQual<T>` and
211
- `UQual<U>` is convertible. Moreover,
212
- `basic_common_reference<T, U, TQual, UQual>::type` shall denote the same
213
- type, if any, as does
214
  `basic_common_reference<U, T, UQual, TQual>::type`. No diagnostic is
215
  required for a violation of these rules.
216
 
217
  [*Example 2*:
218
 
 
1
  ### Transformations between types <a id="meta.trans">[[meta.trans]]</a>
2
 
3
+ #### General <a id="meta.trans.general">[[meta.trans.general]]</a>
 
4
 
5
+ Subclause [[meta.trans]] contains templates that may be used to
6
+ transform one type to another following some predefined rule.
7
+
8
+ Each of the templates in [[meta.trans]] shall be a
9
  *Cpp17TransformationTrait* [[meta.rqmts]].
10
 
11
  #### Const-volatile modifications <a id="meta.trans.cv">[[meta.trans.cv]]</a>
12
 
 
 
 
 
13
  #### Reference modifications <a id="meta.trans.ref">[[meta.trans.ref]]</a>
14
 
 
 
 
15
  #### Sign modifications <a id="meta.trans.sign">[[meta.trans.sign]]</a>
16
 
17
  #### Array modifications <a id="meta.trans.arr">[[meta.trans.arr]]</a>
18
 
 
 
 
 
19
  [*Example 1*:
20
 
21
  ``` cpp
22
  // the following assertions hold:
23
  assert((is_same_v<remove_extent_t<int>, int>));
 
42
 
43
  #### Pointer modifications <a id="meta.trans.ptr">[[meta.trans.ptr]]</a>
44
 
45
  #### Other transformations <a id="meta.trans.other">[[meta.trans.other]]</a>
46
 
47
+ [*Note 1*: The compilation of the expression can result in side effects
48
+ such as the instantiation of class template specializations and function
49
+ template specializations, the generation of implicitly-defined
50
+ functions, and so on. Such side effects are not in the “immediate
51
+ context” and can result in the program being ill-formed. — *end note*]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
  In addition to being available via inclusion of the `<type_traits>`
54
  header, the templates `unwrap_reference`, `unwrap_ref_decay`,
55
  `unwrap_reference_t`, and `unwrap_ref_decay_t` are available when the
56
  header `<functional>` [[functional.syn]] is included.
 
101
  `T` be denoted by `T1` and `T2`, respectively, and let `D1` and `D2`
102
  denote the same types as `decay_t<T1>` and `decay_t<T2>`,
103
  respectively.
104
  - If `is_same_v<T1, D1>` is `false` or `is_same_v<T2, D2>` is `false`,
105
  let `C` denote the same type, if any, as `common_type_t<D1, D2>`.
106
+ - \[*Note 2*: None of the following will apply if there is a
107
  specialization `common_type<D1, D2>`. — *end note*]
108
  - Otherwise, if
109
  ``` cpp
110
  decay_t<decltype(false ? declval<D1>() : declval<D2>())>
111
  ```
 
129
  pursuant to [[namespace.std]], a program may specialize
130
  `common_type<T1, T2>` for types `T1` and `T2` such that
131
  `is_same_v<T1, decay_t<T1>>` and `is_same_v<T2, decay_t<T2>>` are each
132
  `true`.
133
 
134
+ [*Note 3*: Such specializations are needed when only explicit
135
  conversions are desired between the template arguments. — *end note*]
136
 
137
  Such a specialization need not have a member named `type`, but if it
138
+ does, the *qualified-id* `common_type<T1, T2>::type` shall denote a
139
+ cv-unqualified non-reference type to which each of the types `T1` and
140
+ `T2` is explicitly convertible. Moreover, `common_type_t<T1, T2>` shall
141
+ denote the same type, if any, as does `common_type_t<T2, T1>`. No
142
+ diagnostic is required for a violation of this Note’s rules.
 
143
 
144
  Note C: For the `common_reference` trait applied to a parameter pack `T`
145
  of types, the member `type` shall be either defined or not present as
146
  follows:
147
 
 
149
  - Otherwise, if `sizeof...(T)` is one, let `T0` denote the sole type in
150
  the pack `T`. The member typedef `type` shall denote the same type as
151
  `T0`.
152
  - Otherwise, if `sizeof...(T)` is two, let `T1` and `T2` denote the two
153
  types in the pack `T`. Then
154
+ - Let `R` be `COMMON-REF(T1, T2)`. If `T1` and `T2` are reference
155
+ types, `R` is well-formed, and
156
+ `is_convertible_v<add_pointer_t<T1>, add_pointer_t<R>> && is_convertible_v<add_poin{}ter_t<T2>, add_pointer_t<R>>`
157
+ is `true`, then the member typedef `type` denotes `R`.
158
  - Otherwise, if
159
  `basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>,
160
  {}XREF({}T1), XREF(T2)>::type` is well-formed, then the member
161
  typedef `type` denotes that type.
162
  - Otherwise, if `COND-RES(T1, T2)` is well-formed, then the member
 
173
  - Otherwise, there shall be no member `type`.
174
 
175
  Note D: Notwithstanding the provisions of [[meta.type.synop]], and
176
  pursuant to [[namespace.std]], a program may partially specialize
177
  `basic_common_reference<T, U, TQual, UQual>` for types `T` and `U` such
178
+ that `is_same_v<T, decay_t<T>>` and `is_same_v<U, decay_t<U>>` are each
179
+ `true`.
180
 
181
+ [*Note 4*: Such specializations can be used to influence the result of
182
  `common_reference`, and are needed when only explicit conversions are
183
  desired between the template arguments. — *end note*]
184
 
185
  Such a specialization need not have a member named `type`, but if it
186
+ does, the *qualified-id*
187
+ `basic_common_reference<T, U, TQual, UQual>::type` shall denote a type
188
+ to which each of the types `TQual<T>` and `UQual<U>` is convertible.
189
+ Moreover, `basic_common_reference<T, U, TQual, UQual>::type` shall
190
+ denote the same type, if any, as does
191
  `basic_common_reference<U, T, UQual, TQual>::type`. No diagnostic is
192
  required for a violation of these rules.
193
 
194
  [*Example 2*:
195