4.9 KiB
[dcl.name]
9 Declarations [dcl]
9.3 Declarators [dcl.decl]
9.3.2 Type names [dcl.name]
To specify type conversions explicitly,and as an argument ofsizeof,alignof,new, ortypeid, the name of a type shall be specified.
This can be done with atype-id or new-type-id ([expr.new]), which is syntactically a declaration for a variable or function of that type that omits the name of the entity.
type-id:
type-specifier-seq abstract-declaratoropt
defining-type-id:
defining-type-specifier-seq abstract-declaratoropt
abstract-declarator:
ptr-abstract-declarator
noptr-abstract-declaratoropt parameters-and-qualifiers trailing-return-type
abstract-pack-declarator
ptr-abstract-declarator:
noptr-abstract-declarator
ptr-operator ptr-abstract-declaratoropt
noptr-abstract-declarator:
noptr-abstract-declaratoropt parameters-and-qualifiers
noptr-abstract-declaratoropt [ constant-expressionopt ] attribute-specifier-seqopt
( ptr-abstract-declarator )
abstract-pack-declarator:
noptr-abstract-pack-declarator
ptr-operator abstract-pack-declarator
noptr-abstract-pack-declarator:
noptr-abstract-pack-declarator parameters-and-qualifiers
...
It is possible to identify uniquely the location in theabstract-declarator where the identifier would appear if the construction were a declarator in a declaration.
The named type is then the same as the type of the hypothetical identifier.
[Example 1:
int // int iint * // int *piint *[3] // int p[3]int ()[3] // int (*p3i)[3]int *() // int f()int ()(double) // int (*pf)(double) name respectively the types âintâ, âpointer tointâ, âarray of 3 pointers tointâ, âpointer to array of 3intâ, âfunction of (no parameters) returning pointer tointâ, and âpointer to a function of (double) returningintâ.
â end example]
[Note 1:
A type can also be named by a typedef-name, which is introduced by a typedef declaration or alias-declaration ([dcl.typedef]).
â end note]