80 lines
4.9 KiB
Markdown
80 lines
4.9 KiB
Markdown
[dcl.name]
|
||
|
||
# 9 Declarations [[dcl]](./#dcl)
|
||
|
||
## 9.3 Declarators [[dcl.decl]](dcl.decl#dcl.name)
|
||
|
||
### 9.3.2 Type names [dcl.name]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L2557)
|
||
|
||
To specify type conversions explicitly,and as an argument ofsizeof,alignof,new,
|
||
ortypeid,
|
||
the name of a type shall be specified[.](#1.sentence-1)
|
||
|
||
This can be done with a[*type-id*](#nt:type-id "9.3.2 Type names [dcl.name]") or [*new-type-id*](expr.new#nt:new-type-id "7.6.2.8 New [expr.new]") ([[expr.new]](expr.new "7.6.2.8 New")),
|
||
which is syntactically a declaration for a variable or function
|
||
of that type that omits the name of the entity[.](#1.sentence-2)
|
||
|
||
[type-id:](#nt:type-id "9.3.2 Type names [dcl.name]")
|
||
[*type-specifier-seq*](dcl.type.general#nt:type-specifier-seq "9.2.9.1 General [dcl.type.general]") [*abstract-declarator*](#nt:abstract-declarator "9.3.2 Type names [dcl.name]")opt
|
||
|
||
[defining-type-id:](#nt:defining-type-id "9.3.2 Type names [dcl.name]")
|
||
[*defining-type-specifier-seq*](dcl.type.general#nt:defining-type-specifier-seq "9.2.9.1 General [dcl.type.general]") [*abstract-declarator*](#nt:abstract-declarator "9.3.2 Type names [dcl.name]")opt
|
||
|
||
[abstract-declarator:](#nt:abstract-declarator "9.3.2 Type names [dcl.name]")
|
||
[*ptr-abstract-declarator*](#nt:ptr-abstract-declarator "9.3.2 Type names [dcl.name]")
|
||
[*noptr-abstract-declarator*](#nt:noptr-abstract-declarator "9.3.2 Type names [dcl.name]")opt [*parameters-and-qualifiers*](dcl.decl.general#nt:parameters-and-qualifiers "9.3.1 General [dcl.decl.general]") [*trailing-return-type*](dcl.decl.general#nt:trailing-return-type "9.3.1 General [dcl.decl.general]")
|
||
[*abstract-pack-declarator*](#nt:abstract-pack-declarator "9.3.2 Type names [dcl.name]")
|
||
|
||
[ptr-abstract-declarator:](#nt:ptr-abstract-declarator "9.3.2 Type names [dcl.name]")
|
||
[*noptr-abstract-declarator*](#nt:noptr-abstract-declarator "9.3.2 Type names [dcl.name]")
|
||
[*ptr-operator*](dcl.decl.general#nt:ptr-operator "9.3.1 General [dcl.decl.general]") [*ptr-abstract-declarator*](#nt:ptr-abstract-declarator "9.3.2 Type names [dcl.name]")opt
|
||
|
||
[noptr-abstract-declarator:](#nt:noptr-abstract-declarator "9.3.2 Type names [dcl.name]")
|
||
[*noptr-abstract-declarator*](#nt:noptr-abstract-declarator "9.3.2 Type names [dcl.name]")opt [*parameters-and-qualifiers*](dcl.decl.general#nt:parameters-and-qualifiers "9.3.1 General [dcl.decl.general]")
|
||
[*noptr-abstract-declarator*](#nt:noptr-abstract-declarator "9.3.2 Type names [dcl.name]")opt [ [*constant-expression*](expr.const#nt:constant-expression "7.7 Constant expressions [expr.const]")opt ] [*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt
|
||
( [*ptr-abstract-declarator*](#nt:ptr-abstract-declarator "9.3.2 Type names [dcl.name]") )
|
||
|
||
[abstract-pack-declarator:](#nt:abstract-pack-declarator "9.3.2 Type names [dcl.name]")
|
||
[*noptr-abstract-pack-declarator*](#nt:noptr-abstract-pack-declarator "9.3.2 Type names [dcl.name]")
|
||
[*ptr-operator*](dcl.decl.general#nt:ptr-operator "9.3.1 General [dcl.decl.general]") [*abstract-pack-declarator*](#nt:abstract-pack-declarator "9.3.2 Type names [dcl.name]")
|
||
|
||
[noptr-abstract-pack-declarator:](#nt:noptr-abstract-pack-declarator "9.3.2 Type names [dcl.name]")
|
||
[*noptr-abstract-pack-declarator*](#nt:noptr-abstract-pack-declarator "9.3.2 Type names [dcl.name]") [*parameters-and-qualifiers*](dcl.decl.general#nt:parameters-and-qualifiers "9.3.1 General [dcl.decl.general]")
|
||
...
|
||
|
||
It is possible to identify uniquely the location in the[*abstract-declarator*](#nt:abstract-declarator "9.3.2 Type names [dcl.name]") where the identifier would appear if the construction were a declarator
|
||
in a declaration[.](#1.sentence-3)
|
||
|
||
The named type is then the same as the type of the
|
||
hypothetical identifier[.](#1.sentence-4)
|
||
|
||
[*Example [1](#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â[.](#1.sentence-5)
|
||
|
||
â *end example*]
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L2646)
|
||
|
||
[*Note [1](#note-1)*:
|
||
|
||
A type can also be named by a [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4 The typedef specifier [dcl.typedef]"),
|
||
which is introduced by a typedef declaration
|
||
or [*alias-declaration*](dcl.pre#nt:alias-declaration "9.1 Preamble [dcl.pre]") ([[dcl.typedef]](dcl.typedef "9.2.4 The typedef specifier"))[.](#2.sentence-1)
|
||
|
||
â *end note*]
|