tmp/tmps3t7hh48/{from.md → to.md}
RENAMED
|
@@ -1,29 +1,27 @@
|
|
| 1 |
### The `typedef` specifier <a id="dcl.typedef">[[dcl.typedef]]</a>
|
| 2 |
|
| 3 |
-
Declarations containing the *decl-specifier* `typedef` declare
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
in a declaration without a *declarator*, the program is ill-formed.
|
| 12 |
|
| 13 |
``` bnf
|
| 14 |
typedef-name:
|
| 15 |
identifier
|
| 16 |
simple-template-id
|
| 17 |
```
|
| 18 |
|
| 19 |
-
A name declared with the `typedef` specifier becomes a *typedef-name*.
|
| 20 |
-
|
| 21 |
-
[[dcl.decl]] or *simple-template-id* [[temp.pre]]
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
[[dcl.enum]] does.
|
| 25 |
|
| 26 |
[*Example 1*:
|
| 27 |
|
| 28 |
After
|
| 29 |
|
|
@@ -41,16 +39,16 @@ extern KLICKSP metricp;
|
|
| 41 |
are all correct declarations; the type of `distance` is `int` and that
|
| 42 |
of `metricp` is “pointer to `int`”.
|
| 43 |
|
| 44 |
— *end example*]
|
| 45 |
|
| 46 |
-
A
|
| 47 |
*identifier* following the `using` keyword is not looked up; it becomes
|
| 48 |
-
|
| 49 |
-
the *identifier* appertains to that
|
| 50 |
-
|
| 51 |
-
`typedef` specifier.
|
| 52 |
|
| 53 |
[*Example 2*:
|
| 54 |
|
| 55 |
``` cpp
|
| 56 |
using handler_t = void (*)(int);
|
|
@@ -65,11 +63,11 @@ using cell = P<cell*>; // error: cell not found[basic.scope.pdecl]
|
|
| 65 |
The *defining-type-specifier-seq* of the *defining-type-id* shall not
|
| 66 |
define a class or enumeration if the *alias-declaration* is the
|
| 67 |
*declaration* of a *template-declaration*.
|
| 68 |
|
| 69 |
A *simple-template-id* is only a *typedef-name* if its *template-name*
|
| 70 |
-
names an alias template or a template
|
| 71 |
|
| 72 |
[*Note 1*: A *simple-template-id* that names a class template
|
| 73 |
specialization is a *class-name* [[class.name]]. If a *typedef-name* is
|
| 74 |
used to identify the subject of an *elaborated-type-specifier*
|
| 75 |
[[dcl.type.elab]], a class definition [[class]], a constructor
|
|
|
|
| 1 |
### The `typedef` specifier <a id="dcl.typedef">[[dcl.typedef]]</a>
|
| 2 |
|
| 3 |
+
Declarations containing the *decl-specifier* `typedef` declare *type
|
| 4 |
+
aliases*. The `typedef` specifier shall not be combined in a
|
| 5 |
+
*decl-specifier-seq* with any other kind of specifier except a
|
| 6 |
+
*defining-type-specifier*, and it shall not be used in the
|
| 7 |
+
*decl-specifier-seq* of a *parameter-declaration* [[dcl.fct]] nor in the
|
| 8 |
+
*decl-specifier-seq* of a *function-definition* [[dcl.fct.def]]. If a
|
| 9 |
+
`typedef` specifier appears in a declaration without a *declarator*, the
|
| 10 |
+
program is ill-formed.
|
|
|
|
| 11 |
|
| 12 |
``` bnf
|
| 13 |
typedef-name:
|
| 14 |
identifier
|
| 15 |
simple-template-id
|
| 16 |
```
|
| 17 |
|
| 18 |
+
A name declared with the `typedef` specifier becomes a *typedef-name*.
|
| 19 |
+
The underlying entity of the type alias is the type associated with the
|
| 20 |
+
*identifier* [[dcl.decl]] or *simple-template-id* [[temp.pre]]. A
|
| 21 |
+
*typedef-name* does not introduce a new type the way a class declaration
|
| 22 |
+
[[class.name]] or enum declaration [[dcl.enum]] does.
|
|
|
|
| 23 |
|
| 24 |
[*Example 1*:
|
| 25 |
|
| 26 |
After
|
| 27 |
|
|
|
|
| 39 |
are all correct declarations; the type of `distance` is `int` and that
|
| 40 |
of `metricp` is “pointer to `int`”.
|
| 41 |
|
| 42 |
— *end example*]
|
| 43 |
|
| 44 |
+
A type alias can also be declared by an *alias-declaration*. The
|
| 45 |
*identifier* following the `using` keyword is not looked up; it becomes
|
| 46 |
+
the *typedef-name* of a type alias and the optional
|
| 47 |
+
*attribute-specifier-seq* following the *identifier* appertains to that
|
| 48 |
+
type alias. Such a type alias has the same semantics as if it were
|
| 49 |
+
introduced by the `typedef` specifier.
|
| 50 |
|
| 51 |
[*Example 2*:
|
| 52 |
|
| 53 |
``` cpp
|
| 54 |
using handler_t = void (*)(int);
|
|
|
|
| 63 |
The *defining-type-specifier-seq* of the *defining-type-id* shall not
|
| 64 |
define a class or enumeration if the *alias-declaration* is the
|
| 65 |
*declaration* of a *template-declaration*.
|
| 66 |
|
| 67 |
A *simple-template-id* is only a *typedef-name* if its *template-name*
|
| 68 |
+
names an alias template or a type template template parameter.
|
| 69 |
|
| 70 |
[*Note 1*: A *simple-template-id* that names a class template
|
| 71 |
specialization is a *class-name* [[class.name]]. If a *typedef-name* is
|
| 72 |
used to identify the subject of an *elaborated-type-specifier*
|
| 73 |
[[dcl.type.elab]], a class definition [[class]], a constructor
|