From Jason Turner

[meta]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpzf3f3why/{from.md → to.md} +98 -26
tmp/tmpzf3f3why/{from.md → to.md} RENAMED
@@ -39,12 +39,12 @@ shall not be hidden and shall be unambiguously available in the
39
  BinaryTypeTrait.
40
 
41
  A *TransformationTrait* modifies a property of a type. It shall be a
42
  class template that takes one template type argument and, optionally,
43
  additional arguments that help define the modification. It shall define
44
- a nested type named `type`, which shall be a synonym for the modified
45
- type.
46
 
47
  ### Header `<type_traits>` synopsis <a id="meta.type.synop">[[meta.type.synop]]</a>
48
 
49
  ``` cpp
50
  namespace std {
@@ -53,10 +53,11 @@ namespace std {
53
  typedef integral_constant<bool, true> true_type;
54
  typedef integral_constant<bool, false> false_type;
55
 
56
  // [meta.unary.cat], primary type categories:
57
  template <class T> struct is_void;
 
58
  template <class T> struct is_integral;
59
  template <class T> struct is_floating_point;
60
  template <class T> struct is_array;
61
  template <class T> struct is_pointer;
62
  template <class T> struct is_lvalue_reference;
@@ -86,10 +87,11 @@ namespace std {
86
  template <class T> struct is_pod;
87
  template <class T> struct is_literal_type;
88
  template <class T> struct is_empty;
89
  template <class T> struct is_polymorphic;
90
  template <class T> struct is_abstract;
 
91
 
92
  template <class T> struct is_signed;
93
  template <class T> struct is_unsigned;
94
 
95
  template <class T, class... Args> struct is_constructible;
@@ -141,27 +143,62 @@ namespace std {
141
  template <class T> struct remove_cv;
142
  template <class T> struct add_const;
143
  template <class T> struct add_volatile;
144
  template <class T> struct add_cv;
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  // [meta.trans.ref], reference modifications:
147
  template <class T> struct remove_reference;
148
  template <class T> struct add_lvalue_reference;
149
  template <class T> struct add_rvalue_reference;
150
 
 
 
 
 
 
 
 
151
  // [meta.trans.sign], sign modifications:
152
  template <class T> struct make_signed;
153
  template <class T> struct make_unsigned;
154
 
 
 
 
 
 
155
  // [meta.trans.arr], array modifications:
156
  template <class T> struct remove_extent;
157
  template <class T> struct remove_all_extents;
158
 
 
 
 
 
 
159
  // [meta.trans.ptr], pointer modifications:
160
  template <class T> struct remove_pointer;
161
  template <class T> struct add_pointer;
162
 
 
 
 
 
 
163
  // [meta.trans.other], other transformations:
164
  template <std::size_t Len,
165
  std::size_t Align = default-alignment> // see [meta.trans.other]
166
  struct aligned_storage;
167
  template <std::size_t Len, class... Types> struct aligned_union;
@@ -170,10 +207,28 @@ namespace std {
170
  template <bool, class T, class F> struct conditional;
171
  template <class... T> struct common_type;
172
  template <class T> struct underlying_type;
173
  template <class> class result_of; // not defined
174
  template <class F, class... ArgTypes> class result_of<F(ArgTypes...)>;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  } // namespace std
176
  ```
177
 
178
  The behavior of a program that adds specializations for any of the class
179
  templates defined in this subclause is undefined unless otherwise
@@ -186,11 +241,12 @@ namespace std {
186
  template <class T, T v>
187
  struct integral_constant {
188
  static constexpr T value = v;
189
  typedef T value_type;
190
  typedef integral_constant<T,v> type;
191
- constexpr operator value_type() { return value; }
 
192
  };
193
  typedef integral_constant<bool, true> true_type;
194
  typedef integral_constant<bool, false> false_type;
195
  }
196
  ```
@@ -249,21 +305,34 @@ is_const<const int&>::value // false
249
  is_const<int[3]>::value // false
250
  is_const<const int[3]>::value // true
251
  ```
252
 
253
  ``` cpp
254
- remove_const<const volatile int>::type // volatile int
255
- remove_const<const int* const>::type // const int*
256
- remove_const<const int&>::type // const int&
257
- remove_const<const int[3]>::type // int[3]
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  ```
259
 
260
  Given the following function prototype:
261
 
262
  ``` cpp
263
  template <class T>
264
- typename add_rvalue_reference<T>::type create();
265
  ```
266
 
267
  the predicate condition for a template specialization
268
  `is_constructible<T, Args...>` shall be satisfied if and only if the
269
  following variable definition would be well-formed for some invented
@@ -285,10 +354,13 @@ the “immediate context” and can result in the program being ill-formed.
285
  ### Type property queries <a id="meta.unary.prop.query">[[meta.unary.prop.query]]</a>
286
 
287
  This sub-clause contains templates that may be used to query properties
288
  of types at compile time.
289
 
 
 
 
290
  ``` cpp
291
  // the following assertions hold:
292
  assert(rank<int>::value == 0);
293
  assert(rank<int[2]>::value == 1);
294
  assert(rank<int[][4]>::value == 2);
@@ -333,11 +405,11 @@ is_base_of<int, int>::value // false
333
 
334
  Given the following function prototype:
335
 
336
  ``` cpp
337
  template <class T>
338
- typename add_rvalue_reference<T>::type create();
339
  ```
340
 
341
  the predicate condition for a template specialization
342
  `is_convertible<From, To>` shall be satisfied if and only if the return
343
  expression in the following code would be well-formed, including any
@@ -376,22 +448,22 @@ Each of the templates in this subclause shall be a
376
 
377
  #### Array modifications <a id="meta.trans.arr">[[meta.trans.arr]]</a>
378
 
379
  ``` cpp
380
  // the following assertions hold:
381
- assert((is_same<remove_extent<int>::type, int>::value));
382
- assert((is_same<remove_extent<int[2]>::type, int>::value));
383
- assert((is_same<remove_extent<int[2][3]>::type, int[3]>::value));
384
- assert((is_same<remove_extent<int[][3]>::type, int[3]>::value));
385
  ```
386
 
387
  ``` cpp
388
  // the following assertions hold:
389
- assert((is_same<remove_all_extents<int>::type, int>::value));
390
- assert((is_same<remove_all_extents<int[2]>::type, int>::value));
391
- assert((is_same<remove_all_extents<int[2][3]>::type, int>::value));
392
- assert((is_same<remove_all_extents<int[][3]>::type, int>::value));
393
  ```
394
 
395
  #### Pointer modifications <a id="meta.trans.ptr">[[meta.trans.ptr]]</a>
396
 
397
  #### Other transformations <a id="meta.trans.other">[[meta.trans.other]]</a>
@@ -415,21 +487,21 @@ The nested typedef `common_type::type` shall be defined as follows:
415
  ``` cpp
416
  template <class ...T> struct common_type;
417
 
418
  template <class T>
419
  struct common_type<T> {
420
- typedef T type;
421
  };
422
 
423
  template <class T, class U>
424
  struct common_type<T, U> {
425
- typedef decltype(true ? declval<T>() : declval<U>()) type;
426
  };
427
 
428
  template <class T, class U, class... V>
429
  struct common_type<T, U, V...> {
430
- typedef typename common_type<typename common_type<T, U>::type, V...>::type type;
431
  };
432
  ```
433
 
434
  Given these definitions:
435
 
@@ -449,13 +521,13 @@ typedef char S::*PMD;
449
  ```
450
 
451
  the following assertions will hold:
452
 
453
  ``` cpp
454
- static_assert(is_same<result_of<S(int)>::type, short>::value, "Error!");
455
- static_assert(is_same<result_of<S&(unsigned char, int&)>::type, double>::value, "Error!");
456
- static_assert(is_same<result_of<PF1()>::type, bool>::value, "Error!");
457
- static_assert(is_same<result_of<PMF(unique_ptr<S>, int)>::type, void>::value, "Error!");
458
- static_assert(is_same<result_of<PMD(S)>::type, char&&>::value, "Error!");
459
- static_assert(is_same<result_of<PMD(const S*)>::type, const char&>::value, "Error!");
460
  ```
461
 
 
39
  BinaryTypeTrait.
40
 
41
  A *TransformationTrait* modifies a property of a type. It shall be a
42
  class template that takes one template type argument and, optionally,
43
  additional arguments that help define the modification. It shall define
44
+ a publicly accessible nested type named `type`, which shall be a synonym
45
+ for the modified type.
46
 
47
  ### Header `<type_traits>` synopsis <a id="meta.type.synop">[[meta.type.synop]]</a>
48
 
49
  ``` cpp
50
  namespace std {
 
53
  typedef integral_constant<bool, true> true_type;
54
  typedef integral_constant<bool, false> false_type;
55
 
56
  // [meta.unary.cat], primary type categories:
57
  template <class T> struct is_void;
58
+ template <class T> struct is_null_pointer;
59
  template <class T> struct is_integral;
60
  template <class T> struct is_floating_point;
61
  template <class T> struct is_array;
62
  template <class T> struct is_pointer;
63
  template <class T> struct is_lvalue_reference;
 
87
  template <class T> struct is_pod;
88
  template <class T> struct is_literal_type;
89
  template <class T> struct is_empty;
90
  template <class T> struct is_polymorphic;
91
  template <class T> struct is_abstract;
92
+ template <class T> struct is_final;
93
 
94
  template <class T> struct is_signed;
95
  template <class T> struct is_unsigned;
96
 
97
  template <class T, class... Args> struct is_constructible;
 
143
  template <class T> struct remove_cv;
144
  template <class T> struct add_const;
145
  template <class T> struct add_volatile;
146
  template <class T> struct add_cv;
147
 
148
+ template <class T>
149
+ using remove_const_t = typename remove_const<T>::type;
150
+ template <class T>
151
+ using remove_volatile_t = typename remove_volatile<T>::type;
152
+ template <class T>
153
+ using remove_cv_t = typename remove_cv<T>::type;
154
+ template <class T>
155
+ using add_const_t = typename add_const<T>::type;
156
+ template <class T>
157
+ using add_volatile_t = typename add_volatile<T>::type;
158
+ template <class T>
159
+ using add_cv_t = typename add_cv<T>::type;
160
+
161
  // [meta.trans.ref], reference modifications:
162
  template <class T> struct remove_reference;
163
  template <class T> struct add_lvalue_reference;
164
  template <class T> struct add_rvalue_reference;
165
 
166
+ template <class T>
167
+ using remove_reference_t = typename remove_reference<T>::type;
168
+ template <class T>
169
+ using add_lvalue_reference_t = typename add_lvalue_reference<T>::type;
170
+ template <class T>
171
+ using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;
172
+
173
  // [meta.trans.sign], sign modifications:
174
  template <class T> struct make_signed;
175
  template <class T> struct make_unsigned;
176
 
177
+ template <class T>
178
+ using make_signed_t = typename make_signed<T>::type;
179
+ template <class T>
180
+ using make_unsigned_t = typename make_unsigned<T>::type;
181
+
182
  // [meta.trans.arr], array modifications:
183
  template <class T> struct remove_extent;
184
  template <class T> struct remove_all_extents;
185
 
186
+ template <class T>
187
+ using remove_extent_t = typename remove_extent<T>::type;
188
+ template <class T>
189
+ using remove_all_extents_t = typename remove_all_extents<T>::type;
190
+
191
  // [meta.trans.ptr], pointer modifications:
192
  template <class T> struct remove_pointer;
193
  template <class T> struct add_pointer;
194
 
195
+ template <class T>
196
+ using remove_pointer_t = typename remove_pointer<T>::type;
197
+ template <class T>
198
+ using add_pointer_t = typename add_pointer<T>::type;
199
+
200
  // [meta.trans.other], other transformations:
201
  template <std::size_t Len,
202
  std::size_t Align = default-alignment> // see [meta.trans.other]
203
  struct aligned_storage;
204
  template <std::size_t Len, class... Types> struct aligned_union;
 
207
  template <bool, class T, class F> struct conditional;
208
  template <class... T> struct common_type;
209
  template <class T> struct underlying_type;
210
  template <class> class result_of; // not defined
211
  template <class F, class... ArgTypes> class result_of<F(ArgTypes...)>;
212
+
213
+ template <std::size_t Len,
214
+ std::size_t Align = default-alignment > // see [meta.trans.other]
215
+ using aligned_storage_t = typename aligned_storage<Len,Align>::type;
216
+ template <std::size_t Len, class... Types>
217
+ using aligned_union_t = typename aligned_union<Len,Types...>::type;
218
+ template <class T>
219
+ using decay_t = typename decay<T>::type;
220
+ template <bool b, class T = void>
221
+ using enable_if_t = typename enable_if<b,T>::type;
222
+ template <bool b, class T, class F>
223
+ using conditional_t = typename conditional<b,T,F>::type;
224
+ template <class... T>
225
+ using common_type_t = typename common_type<T...>::type;
226
+ template <class T>
227
+ using underlying_type_t = typename underlying_type<T>::type;
228
+ template <class T>
229
+ using result_of_t = typename result_of<T>::type;
230
  } // namespace std
231
  ```
232
 
233
  The behavior of a program that adds specializations for any of the class
234
  templates defined in this subclause is undefined unless otherwise
 
241
  template <class T, T v>
242
  struct integral_constant {
243
  static constexpr T value = v;
244
  typedef T value_type;
245
  typedef integral_constant<T,v> type;
246
+ constexpr operator value_type() const noexcept { return value; }
247
+ constexpr value_type operator()() const noexcept { return value; }
248
  };
249
  typedef integral_constant<bool, true> true_type;
250
  typedef integral_constant<bool, false> false_type;
251
  }
252
  ```
 
305
  is_const<int[3]>::value // false
306
  is_const<const int[3]>::value // true
307
  ```
308
 
309
  ``` cpp
310
+ remove_const_t<const volatile int> // volatile int
311
+ remove_const_t<const int* const> // const int*
312
+ remove_const_t<const int&> // const int&
313
+ remove_const_t<const int[3]> // int[3]
314
+ ```
315
+
316
+ ``` cpp
317
+ // Given:
318
+ struct P final { };
319
+ union U1 { };
320
+ union U2 final { };
321
+
322
+ // the following assertions hold:
323
+ static_assert(!is_final<int>::value, "Error!");
324
+ static_assert( is_final<P>::value, "Error!");
325
+ static_assert(!is_final<U1>::value, "Error!");
326
+ static_assert( is_final<U2>::value, "Error!");
327
  ```
328
 
329
  Given the following function prototype:
330
 
331
  ``` cpp
332
  template <class T>
333
+ add_rvalue_reference_t<T> create() noexcept;
334
  ```
335
 
336
  the predicate condition for a template specialization
337
  `is_constructible<T, Args...>` shall be satisfied if and only if the
338
  following variable definition would be well-formed for some invented
 
354
  ### Type property queries <a id="meta.unary.prop.query">[[meta.unary.prop.query]]</a>
355
 
356
  This sub-clause contains templates that may be used to query properties
357
  of types at compile time.
358
 
359
+ Each of these templates shall be a `UnaryTypeTrait` ([[meta.rqmts]])
360
+ with a `BaseCharacteristic` of `integral_constant<size_t, Value>`.
361
+
362
  ``` cpp
363
  // the following assertions hold:
364
  assert(rank<int>::value == 0);
365
  assert(rank<int[2]>::value == 1);
366
  assert(rank<int[][4]>::value == 2);
 
405
 
406
  Given the following function prototype:
407
 
408
  ``` cpp
409
  template <class T>
410
+ add_rvalue_reference_t<T> create() noexcept;
411
  ```
412
 
413
  the predicate condition for a template specialization
414
  `is_convertible<From, To>` shall be satisfied if and only if the return
415
  expression in the following code would be well-formed, including any
 
448
 
449
  #### Array modifications <a id="meta.trans.arr">[[meta.trans.arr]]</a>
450
 
451
  ``` cpp
452
  // the following assertions hold:
453
+ assert((is_same<remove_extent_t<int>, int>::value));
454
+ assert((is_same<remove_extent_t<int[2]>, int>::value));
455
+ assert((is_same<remove_extent_t<int[2][3]>, int[3]>::value));
456
+ assert((is_same<remove_extent_t<int[][3]>, int[3]>::value));
457
  ```
458
 
459
  ``` cpp
460
  // the following assertions hold:
461
+ assert((is_same<remove_all_extents_t<int>, int>::value));
462
+ assert((is_same<remove_all_extents_t<int[2]>, int>::value));
463
+ assert((is_same<remove_all_extents_t<int[2][3]>, int>::value));
464
+ assert((is_same<remove_all_extents_t<int[][3]>, int>::value));
465
  ```
466
 
467
  #### Pointer modifications <a id="meta.trans.ptr">[[meta.trans.ptr]]</a>
468
 
469
  #### Other transformations <a id="meta.trans.other">[[meta.trans.other]]</a>
 
487
  ``` cpp
488
  template <class ...T> struct common_type;
489
 
490
  template <class T>
491
  struct common_type<T> {
492
+ typedef decay_t<T> type;
493
  };
494
 
495
  template <class T, class U>
496
  struct common_type<T, U> {
497
+ typedef decay_t<decltype(true ? declval<T>() : declval<U>())> type;
498
  };
499
 
500
  template <class T, class U, class... V>
501
  struct common_type<T, U, V...> {
502
+ typedef common_type_t<common_type_t<T, U>, V...> type;
503
  };
504
  ```
505
 
506
  Given these definitions:
507
 
 
521
  ```
522
 
523
  the following assertions will hold:
524
 
525
  ``` cpp
526
+ static_assert(is_same<result_of_t<S(int)>, short>::value, "Error!");
527
+ static_assert(is_same<result_of_t<S&(unsigned char, int&)>, double>::value, "Error!");
528
+ static_assert(is_same<result_of_t<PF1()>, bool>::value, "Error!");
529
+ static_assert(is_same<result_of_t<PMF(unique_ptr<S>, int)>, void>::value, "Error!");
530
+ static_assert(is_same<result_of_t<PMD(S)>, char&&>::value, "Error!");
531
+ static_assert(is_same<result_of_t<PMD(const S*)>, const char&>::value, "Error!");
532
  ```
533