- tmp/tmpibb05dyj/{from.md → to.md} +79 -158
tmp/tmpibb05dyj/{from.md → to.md}
RENAMED
|
@@ -3,190 +3,111 @@
|
|
| 3 |
The simple type specifiers are
|
| 4 |
|
| 5 |
``` bnf
|
| 6 |
simple-type-specifier:
|
| 7 |
nested-name-specifierₒₚₜ type-name
|
| 8 |
-
nested-name-specifier
|
| 9 |
-
nested-name-specifierₒₚₜ template-name
|
| 10 |
-
'char'
|
| 11 |
-
'char16_t'
|
| 12 |
-
'char32_t'
|
| 13 |
-
'wchar_t'
|
| 14 |
-
'bool'
|
| 15 |
-
'short'
|
| 16 |
-
'int'
|
| 17 |
-
'long'
|
| 18 |
-
'signed'
|
| 19 |
-
'unsigned'
|
| 20 |
-
'float'
|
| 21 |
-
'double'
|
| 22 |
-
'void'
|
| 23 |
-
'auto'
|
| 24 |
decltype-specifier
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
```
|
| 26 |
|
| 27 |
``` bnf
|
| 28 |
type-name:
|
| 29 |
class-name
|
| 30 |
enum-name
|
| 31 |
typedef-name
|
| 32 |
-
simple-template-id
|
| 33 |
```
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
``` bnf
|
| 36 |
-
|
| 37 |
-
'decltype' '(' expression ')'
|
| 38 |
-
'decltype' '(' 'auto' ')'
|
| 39 |
```
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
`typename`ₒₚₜ *nested-name-specifier*ₒₚₜ *template-name* is a
|
| 44 |
-
placeholder for a deduced class type ([[dcl.type.class.deduct]]). The
|
| 45 |
-
*template-name* shall name a class template that is not an
|
| 46 |
-
injected-class-name. The other *simple-type-specifier*s specify either a
|
| 47 |
-
previously-declared type, a type determined from an expression, or one
|
| 48 |
-
of the fundamental types ([[basic.fundamental]]). Table
|
| 49 |
-
[[tab:simple.type.specifiers]] summarizes the valid combinations of
|
| 50 |
-
*simple-type-specifier*s and the types they specify.
|
| 51 |
|
| 52 |
-
**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
| Specifier(s) | Type |
|
| 55 |
-
| ---------------------- | -------------------------------------- |
|
| 56 |
| *type-name* | the type named |
|
| 57 |
| *simple-template-id* | the type as defined in~ [[temp.names]] |
|
| 58 |
-
| *
|
| 59 |
-
|
|
| 60 |
-
|
|
| 61 |
-
|
|
| 62 |
-
|
|
| 63 |
-
|
|
| 64 |
-
|
|
| 65 |
-
|
|
| 66 |
-
|
|
| 67 |
-
|
|
| 68 |
-
|
|
| 69 |
-
| int
|
| 70 |
-
|
|
| 71 |
-
|
|
| 72 |
-
|
|
| 73 |
-
| unsigned
|
| 74 |
-
| unsigned
|
| 75 |
-
| unsigned long
|
| 76 |
-
|
|
| 77 |
-
|
|
| 78 |
-
|
|
| 79 |
-
| signed long
|
| 80 |
-
|
|
| 81 |
-
| long long
|
| 82 |
-
| long
|
| 83 |
-
| long
|
| 84 |
-
|
|
| 85 |
-
|
|
| 86 |
-
|
|
| 87 |
-
| short
|
| 88 |
-
|
|
| 89 |
-
|
|
| 90 |
-
|
|
| 91 |
-
|
|
| 92 |
-
|
|
| 93 |
-
|
|
| 94 |
-
|
|
| 95 |
-
|
|
| 96 |
|
| 97 |
|
| 98 |
When multiple *simple-type-specifier*s are allowed, they can be freely
|
| 99 |
intermixed with other *decl-specifier*s in any order.
|
| 100 |
|
| 101 |
-
[*Note
|
| 102 |
type are represented as signed or unsigned quantities. The `signed`
|
| 103 |
specifier forces `char` objects to be signed; it is redundant in other
|
| 104 |
contexts. — *end note*]
|
| 105 |
|
| 106 |
-
For an expression `e`, the type denoted by `decltype(e)` is defined as
|
| 107 |
-
follows:
|
| 108 |
-
|
| 109 |
-
- if `e` is an unparenthesized *id-expression* naming a structured
|
| 110 |
-
binding ([[dcl.struct.bind]]), `decltype(e)` is the referenced type
|
| 111 |
-
as given in the specification of the structured binding declaration;
|
| 112 |
-
- otherwise, if `e` is an unparenthesized *id-expression* or an
|
| 113 |
-
unparenthesized class member access ([[expr.ref]]), `decltype(e)` is
|
| 114 |
-
the type of the entity named by `e`. If there is no such entity, or if
|
| 115 |
-
`e` names a set of overloaded functions, the program is ill-formed;
|
| 116 |
-
- otherwise, if `e` is an xvalue, `decltype(e)` is `T&&`, where `T` is
|
| 117 |
-
the type of `e`;
|
| 118 |
-
- otherwise, if `e` is an lvalue, `decltype(e)` is `T&`, where `T` is
|
| 119 |
-
the type of `e`;
|
| 120 |
-
- otherwise, `decltype(e)` is the type of `e`.
|
| 121 |
-
|
| 122 |
-
The operand of the `decltype` specifier is an unevaluated operand
|
| 123 |
-
(Clause [[expr]]).
|
| 124 |
-
|
| 125 |
-
[*Example 1*:
|
| 126 |
-
|
| 127 |
-
``` cpp
|
| 128 |
-
const int&& foo();
|
| 129 |
-
int i;
|
| 130 |
-
struct A { double x; };
|
| 131 |
-
const A* a = new A();
|
| 132 |
-
decltype(foo()) x1 = 17; // type is const int&&
|
| 133 |
-
decltype(i) x2; // type is int
|
| 134 |
-
decltype(a->x) x3; // type is double
|
| 135 |
-
decltype((a->x)) x4 = x3; // type is const double&
|
| 136 |
-
```
|
| 137 |
-
|
| 138 |
-
— *end example*]
|
| 139 |
-
|
| 140 |
-
[*Note 2*: The rules for determining types involving `decltype(auto)`
|
| 141 |
-
are specified in [[dcl.spec.auto]]. — *end note*]
|
| 142 |
-
|
| 143 |
-
If the operand of a *decltype-specifier* is a prvalue, the temporary
|
| 144 |
-
materialization conversion is not applied ([[conv.rval]]) and no result
|
| 145 |
-
object is provided for the prvalue. The type of the prvalue may be
|
| 146 |
-
incomplete.
|
| 147 |
-
|
| 148 |
-
[*Note 3*: As a result, storage is not allocated for the prvalue and it
|
| 149 |
-
is not destroyed. Thus, a class type is not instantiated as a result of
|
| 150 |
-
being the type of a function call in this context. In this context, the
|
| 151 |
-
common purpose of writing the expression is merely to refer to its type.
|
| 152 |
-
In that sense, a *decltype-specifier* is analogous to a use of a
|
| 153 |
-
*typedef-name*, so the usual reasons for requiring a complete type do
|
| 154 |
-
not apply. In particular, it is not necessary to allocate storage for a
|
| 155 |
-
temporary object or to enforce the semantic constraints associated with
|
| 156 |
-
invoking the type’s destructor. — *end note*]
|
| 157 |
-
|
| 158 |
-
[*Note 4*: Unlike the preceding rule, parentheses have no special
|
| 159 |
-
meaning in this context. — *end note*]
|
| 160 |
-
|
| 161 |
-
[*Example 2*:
|
| 162 |
-
|
| 163 |
-
``` cpp
|
| 164 |
-
template<class T> struct A { ~A() = delete; };
|
| 165 |
-
template<class T> auto h()
|
| 166 |
-
-> A<T>;
|
| 167 |
-
template<class T> auto i(T) // identity
|
| 168 |
-
-> T;
|
| 169 |
-
template<class T> auto f(T) // #1
|
| 170 |
-
-> decltype(i(h<T>())); // forces completion of A<T> and implicitly uses A<T>::~A()
|
| 171 |
-
// for the temporary introduced by the use of h().
|
| 172 |
-
// (A temporary is not introduced as a result of the use of i().)
|
| 173 |
-
template<class T> auto f(T) // #2
|
| 174 |
-
-> void;
|
| 175 |
-
auto g() -> void {
|
| 176 |
-
f(42); // OK: calls #2. (#1 is not a viable candidate: type deduction
|
| 177 |
-
// fails~([temp.deduct]) because A<int>::~{A()} is implicitly used in its
|
| 178 |
-
// decltype-specifier)
|
| 179 |
-
}
|
| 180 |
-
template<class T> auto q(T)
|
| 181 |
-
-> decltype((h<T>())); // does not force completion of A<T>; A<T>::~A() is not implicitly
|
| 182 |
-
// used within the context of this decltype-specifier
|
| 183 |
-
void r() {
|
| 184 |
-
q(42); // Error: deduction against q succeeds, so overload resolution selects
|
| 185 |
-
// the specialization ``q(T) -> decltype((h<T>())) [with T=int]''.
|
| 186 |
-
// The return type is A<int>, so a temporary is introduced and its
|
| 187 |
-
// destructor is used, so the program is ill-formed.
|
| 188 |
-
}
|
| 189 |
-
```
|
| 190 |
-
|
| 191 |
-
— *end example*]
|
| 192 |
-
|
|
|
|
| 3 |
The simple type specifiers are
|
| 4 |
|
| 5 |
``` bnf
|
| 6 |
simple-type-specifier:
|
| 7 |
nested-name-specifierₒₚₜ type-name
|
| 8 |
+
nested-name-specifier template simple-template-id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
decltype-specifier
|
| 10 |
+
placeholder-type-specifier
|
| 11 |
+
nested-name-specifierₒₚₜ template-name
|
| 12 |
+
char
|
| 13 |
+
char8_t
|
| 14 |
+
char16_t
|
| 15 |
+
char32_t
|
| 16 |
+
wchar_t
|
| 17 |
+
bool
|
| 18 |
+
short
|
| 19 |
+
int
|
| 20 |
+
long
|
| 21 |
+
signed
|
| 22 |
+
unsigned
|
| 23 |
+
float
|
| 24 |
+
double
|
| 25 |
+
void
|
| 26 |
```
|
| 27 |
|
| 28 |
``` bnf
|
| 29 |
type-name:
|
| 30 |
class-name
|
| 31 |
enum-name
|
| 32 |
typedef-name
|
|
|
|
| 33 |
```
|
| 34 |
|
| 35 |
+
A *placeholder-type-specifier* is a placeholder for a type to be deduced
|
| 36 |
+
[[dcl.spec.auto]]. A *type-specifier* of the form `typename`ₒₚₜ
|
| 37 |
+
*nested-name-specifier*ₒₚₜ *template-name* is a placeholder for a
|
| 38 |
+
deduced class type [[dcl.type.class.deduct]]. The
|
| 39 |
+
*nested-name-specifier*, if any, shall be non-dependent and the
|
| 40 |
+
*template-name* shall name a deducible template. A *deducible template*
|
| 41 |
+
is either a class template or is an alias template whose
|
| 42 |
+
*defining-type-id* is of the form
|
| 43 |
+
|
| 44 |
``` bnf
|
| 45 |
+
typenameₒₚₜ nested-name-specifierₒₚₜ templateₒₚₜ simple-template-id
|
|
|
|
|
|
|
| 46 |
```
|
| 47 |
|
| 48 |
+
where the *nested-name-specifier* (if any) is non-dependent and the
|
| 49 |
+
*template-name* of the *simple-template-id* names a deducible template.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
+
[*Note 1*: An injected-class-name is never interpreted as a
|
| 52 |
+
*template-name* in contexts where class template argument deduction
|
| 53 |
+
would be performed [[temp.local]]. — *end note*]
|
| 54 |
+
|
| 55 |
+
The other *simple-type-specifier*s specify either a previously-declared
|
| 56 |
+
type, a type determined from an expression, or one of the fundamental
|
| 57 |
+
types [[basic.fundamental]]. [[dcl.type.simple]] summarizes the valid
|
| 58 |
+
combinations of *simple-type-specifier*s and the types they specify.
|
| 59 |
+
|
| 60 |
+
**Table: *simple-type-specifier*{s} and the types they specify** <a id="dcl.type.simple">[dcl.type.simple]</a>
|
| 61 |
|
| 62 |
| Specifier(s) | Type |
|
| 63 |
+
| ---------------------------- | ------------------------------------------------- |
|
| 64 |
| *type-name* | the type named |
|
| 65 |
| *simple-template-id* | the type as defined in~ [[temp.names]] |
|
| 66 |
+
| *decltype-specifier* | the type as defined in~ [[dcl.type.decltype]] |
|
| 67 |
+
| *placeholder-type-specifier* | the type as defined in~ [[dcl.spec.auto]] |
|
| 68 |
+
| *template-name* | the type as defined in~ [[dcl.type.class.deduct]] |
|
| 69 |
+
| `char` | ```char`'' |
|
| 70 |
+
| `unsigned char` | ```unsigned char`'' |
|
| 71 |
+
| `signed char` | ```signed char`'' |
|
| 72 |
+
| `char8_t` | ```char8_t`'' |
|
| 73 |
+
| `char16_t` | ```char16_t`'' |
|
| 74 |
+
| `char32_t` | ```char32_t`'' |
|
| 75 |
+
| `bool` | ```bool`'' |
|
| 76 |
+
| `unsigned` | ```unsigned int`'' |
|
| 77 |
+
| `unsigned int` | ```unsigned int`'' |
|
| 78 |
+
| `signed` | ```int`'' |
|
| 79 |
+
| `signed int` | ```int`'' |
|
| 80 |
+
| `int` | ```int`'' |
|
| 81 |
+
| `unsigned short int` | ```unsigned short int`'' |
|
| 82 |
+
| `unsigned short` | ```unsigned short int`'' |
|
| 83 |
+
| `unsigned long int` | ```unsigned long int`'' |
|
| 84 |
+
| `unsigned long` | ```unsigned long int`'' |
|
| 85 |
+
| `unsigned long long int` | ```unsigned long long int`'' |
|
| 86 |
+
| `unsigned long long` | ```unsigned long long int`'' |
|
| 87 |
+
| `signed long int` | ```long int`'' |
|
| 88 |
+
| `signed long` | ```long int`'' |
|
| 89 |
+
| `signed long long int` | ```long long int`'' |
|
| 90 |
+
| `signed long long` | ```long long int`'' |
|
| 91 |
+
| `long long int` | ```long long int`'' |
|
| 92 |
+
| `long long` | ```long long int`'' |
|
| 93 |
+
| `long int` | ```long int`'' |
|
| 94 |
+
| `long` | ```long int`'' |
|
| 95 |
+
| `signed short int` | ```short int`'' |
|
| 96 |
+
| `signed short` | ```short int`'' |
|
| 97 |
+
| `short int` | ```short int`'' |
|
| 98 |
+
| `short` | ```short int`'' |
|
| 99 |
+
| `wchar_t` | ```wchar_t`'' |
|
| 100 |
+
| `float` | ```float`'' |
|
| 101 |
+
| `double` | ```double`'' |
|
| 102 |
+
| `long double` | ```long double`'' |
|
| 103 |
+
| `void` | ```void`'' |
|
| 104 |
|
| 105 |
|
| 106 |
When multiple *simple-type-specifier*s are allowed, they can be freely
|
| 107 |
intermixed with other *decl-specifier*s in any order.
|
| 108 |
|
| 109 |
+
[*Note 2*: It is *implementation-defined* whether objects of `char`
|
| 110 |
type are represented as signed or unsigned quantities. The `signed`
|
| 111 |
specifier forces `char` objects to be signed; it is redundant in other
|
| 112 |
contexts. — *end note*]
|
| 113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|