From Jason Turner

[meta.unary]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpougmckbb/{from.md → to.md} +72 -34
tmp/tmpougmckbb/{from.md → to.md} RENAMED
@@ -1,96 +1,134 @@
1
  ### Unary type traits <a id="meta.unary">[[meta.unary]]</a>
2
 
3
- This sub-clause contains templates that may be used to query the
4
  properties of a type at compile time.
5
 
6
- Each of these templates shall be a UnaryTypeTrait ([[meta.rqmts]]) with
7
- a BaseCharacteristic of `true_type` if the corresponding condition is
8
- true, otherwise `false_type`.
9
 
10
  #### Primary type categories <a id="meta.unary.cat">[[meta.unary.cat]]</a>
11
 
12
  The primary type categories correspond to the descriptions given in
13
  section  [[basic.types]] of the C++standard.
14
 
15
  For any given type `T`, the result of applying one of these templates to
16
- `T` and to *cv-qualified* `T` shall yield the same result.
17
 
18
- For any given type `T`, exactly one of the primary type categories has a
19
- `value` member that evaluates to `true`.
20
 
21
  #### Composite type traits <a id="meta.unary.comp">[[meta.unary.comp]]</a>
22
 
23
  These templates provide convenient compositions of the primary type
24
  categories, corresponding to the descriptions given in section 
25
  [[basic.types]].
26
 
27
  For any given type `T`, the result of applying one of these templates to
28
- `T`, and to *cv-qualified* `T` shall yield the same result.
29
 
30
  #### Type properties <a id="meta.unary.prop">[[meta.unary.prop]]</a>
31
 
32
  These templates provide access to some of the more important properties
33
  of types.
34
 
35
  It is unspecified whether the library defines any full or partial
36
  specializations of any of these templates.
37
 
38
- For all of the class templates `X` declared in this Clause,
39
  instantiating that template with a template-argument that is a class
40
  template specialization may result in the implicit instantiation of the
41
  template argument if and only if the semantics of `X` require that the
42
  argument must be a complete type.
43
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  ``` cpp
45
- is_const<const volatile int>::value // true
46
- is_const<const int*>::value // false
47
- is_const<const int&>::value // false
48
- is_const<int[3]>::value // false
49
- is_const<const int[3]>::value // true
50
  ```
51
 
 
 
 
 
52
  ``` cpp
53
  remove_const_t<const volatile int> // volatile int
54
  remove_const_t<const int* const> // const int*
55
  remove_const_t<const int&> // const int&
56
  remove_const_t<const int[3]> // int[3]
57
  ```
58
 
 
 
 
 
59
  ``` cpp
60
  // Given:
61
  struct P final { };
62
  union U1 { };
63
  union U2 final { };
64
 
65
  // the following assertions hold:
66
- static_assert(!is_final<int>::value, "Error!");
67
- static_assert( is_final<P>::value, "Error!");
68
- static_assert(!is_final<U1>::value, "Error!");
69
- static_assert( is_final<U2>::value, "Error!");
70
  ```
71
 
72
- Given the following function prototype:
73
 
74
- ``` cpp
75
- template <class T>
76
- add_rvalue_reference_t<T> create() noexcept;
77
- ```
78
-
79
- the predicate condition for a template specialization
80
  `is_constructible<T, Args...>` shall be satisfied if and only if the
81
  following variable definition would be well-formed for some invented
82
  variable `t`:
83
 
84
  ``` cpp
85
- T t(create<Args>()...);
86
  ```
87
 
88
- These tokens are never interpreted as a function declaration. Access
89
- checking is performed as if in a context unrelated to `T` and any of the
90
- `Args`. Only the validity of the immediate context of the variable
91
- initialization is considered. The evaluation of the initialization can
92
- result in side effects such as the instantiation of class template
93
- specializations and function template specializations, the generation of
94
- implicitly-defined functions, and so on. Such side effects are not in
95
- the “immediate context” and can result in the program being ill-formed.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
 
1
  ### Unary type traits <a id="meta.unary">[[meta.unary]]</a>
2
 
3
+ This subclause contains templates that may be used to query the
4
  properties of a type at compile time.
5
 
6
+ Each of these templates shall be a `UnaryTypeTrait` ([[meta.rqmts]])
7
+ with a base characteristic of `true_type` if the corresponding condition
8
+ is `true`, otherwise `false_type`.
9
 
10
  #### Primary type categories <a id="meta.unary.cat">[[meta.unary.cat]]</a>
11
 
12
  The primary type categories correspond to the descriptions given in
13
  section  [[basic.types]] of the C++standard.
14
 
15
  For any given type `T`, the result of applying one of these templates to
16
+ `T` and to cv `T` shall yield the same result.
17
 
18
+ [*Note 1*: For any given type `T`, exactly one of the primary type
19
+ categories has a `value` member that evaluates to `true`. — *end note*]
20
 
21
  #### Composite type traits <a id="meta.unary.comp">[[meta.unary.comp]]</a>
22
 
23
  These templates provide convenient compositions of the primary type
24
  categories, corresponding to the descriptions given in section 
25
  [[basic.types]].
26
 
27
  For any given type `T`, the result of applying one of these templates to
28
+ `T` and to cv `T` shall yield the same result.
29
 
30
  #### Type properties <a id="meta.unary.prop">[[meta.unary.prop]]</a>
31
 
32
  These templates provide access to some of the more important properties
33
  of types.
34
 
35
  It is unspecified whether the library defines any full or partial
36
  specializations of any of these templates.
37
 
38
+ For all of the class templates `X` declared in this subclause,
39
  instantiating that template with a template-argument that is a class
40
  template specialization may result in the implicit instantiation of the
41
  template argument if and only if the semantics of `X` require that the
42
  argument must be a complete type.
43
 
44
+ For the purpose of defining the templates in this subclause, a function
45
+ call expression `declval<T>()` for any type `T` is considered to be a
46
+ trivial ([[basic.types]], [[special]]) function call that is not an
47
+ odr-use ([[basic.def.odr]]) of `declval` in the context of the
48
+ corresponding definition notwithstanding the restrictions of 
49
+ [[declval]].
50
+
51
+ [*Note 1*: A union is a class type that can be marked with
52
+ `final`. — *end note*]
53
+
54
+ [*Example 1*:
55
+
56
  ``` cpp
57
+ is_const_v<const volatile int> // true
58
+ is_const_v<const int*> // false
59
+ is_const_v<const int&> // false
60
+ is_const_v<int[3]> // false
61
+ is_const_v<const int[3]> // true
62
  ```
63
 
64
+ — *end example*]
65
+
66
+ [*Example 2*:
67
+
68
  ``` cpp
69
  remove_const_t<const volatile int> // volatile int
70
  remove_const_t<const int* const> // const int*
71
  remove_const_t<const int&> // const int&
72
  remove_const_t<const int[3]> // int[3]
73
  ```
74
 
75
+ — *end example*]
76
+
77
+ [*Example 3*:
78
+
79
  ``` cpp
80
  // Given:
81
  struct P final { };
82
  union U1 { };
83
  union U2 final { };
84
 
85
  // the following assertions hold:
86
+ static_assert(!is_final_v<int>);
87
+ static_assert(is_final_v<P>);
88
+ static_assert(!is_final_v<U1>);
89
+ static_assert(is_final_v<U2>);
90
  ```
91
 
92
+ *end example*]
93
 
94
+ The predicate condition for a template specialization
 
 
 
 
 
95
  `is_constructible<T, Args...>` shall be satisfied if and only if the
96
  following variable definition would be well-formed for some invented
97
  variable `t`:
98
 
99
  ``` cpp
100
+ T t(declval<Args>()...);
101
  ```
102
 
103
+ [*Note 2*: These tokens are never interpreted as a function
104
+ declaration. *end note*]
105
+
106
+ Access checking is performed as if in a context unrelated to `T` and any
107
+ of the `Args`. Only the validity of the immediate context of the
108
+ variable initialization is considered.
109
+
110
+ [*Note 3*: The evaluation of the initialization can result in side
111
+ effects such as the instantiation of class template specializations and
112
+ function template specializations, the generation of implicitly-defined
113
+ functions, and so on. Such side effects are not in the “immediate
114
+ context” and can result in the program being ill-formed. — *end note*]
115
+
116
+ The predicate condition for a template specialization
117
+ `has_unique_object_representations<T>` shall be satisfied if and only
118
+ if:
119
+
120
+ - `T` is trivially copyable, and
121
+ - any two objects of type `T` with the same value have the same object
122
+ representation, where two objects of array or non-union class type are
123
+ considered to have the same value if their respective sequences of
124
+ direct subobjects have the same values, and two objects of union type
125
+ are considered to have the same value if they have the same active
126
+ member and the corresponding members have the same value.
127
+
128
+ The set of scalar types for which this condition holds is
129
+ *implementation-defined*.
130
+
131
+ [*Note 4*: If a type has padding bits, the condition does not hold;
132
+ otherwise, the condition holds true for unsigned integral
133
+ types. — *end note*]
134