Files
2025-10-25 03:02:53 +03:00

80 lines
4.9 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[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.2Type names[dcl.name]") or [*new-type-id*](expr.new#nt:new-type-id "7.6.2.8New[expr.new]") ([[expr.new]](expr.new "7.6.2.8New")),
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.2Type names[dcl.name]")
[*type-specifier-seq*](dcl.type.general#nt:type-specifier-seq "9.2.9.1General[dcl.type.general]") [*abstract-declarator*](#nt:abstract-declarator "9.3.2Type names[dcl.name]")opt
[defining-type-id:](#nt:defining-type-id "9.3.2Type names[dcl.name]")
[*defining-type-specifier-seq*](dcl.type.general#nt:defining-type-specifier-seq "9.2.9.1General[dcl.type.general]") [*abstract-declarator*](#nt:abstract-declarator "9.3.2Type names[dcl.name]")opt
[abstract-declarator:](#nt:abstract-declarator "9.3.2Type names[dcl.name]")
[*ptr-abstract-declarator*](#nt:ptr-abstract-declarator "9.3.2Type names[dcl.name]")
[*noptr-abstract-declarator*](#nt:noptr-abstract-declarator "9.3.2Type names[dcl.name]")opt [*parameters-and-qualifiers*](dcl.decl.general#nt:parameters-and-qualifiers "9.3.1General[dcl.decl.general]") [*trailing-return-type*](dcl.decl.general#nt:trailing-return-type "9.3.1General[dcl.decl.general]")
[*abstract-pack-declarator*](#nt:abstract-pack-declarator "9.3.2Type names[dcl.name]")
[ptr-abstract-declarator:](#nt:ptr-abstract-declarator "9.3.2Type names[dcl.name]")
[*noptr-abstract-declarator*](#nt:noptr-abstract-declarator "9.3.2Type names[dcl.name]")
[*ptr-operator*](dcl.decl.general#nt:ptr-operator "9.3.1General[dcl.decl.general]") [*ptr-abstract-declarator*](#nt:ptr-abstract-declarator "9.3.2Type names[dcl.name]")opt
[noptr-abstract-declarator:](#nt:noptr-abstract-declarator "9.3.2Type names[dcl.name]")
[*noptr-abstract-declarator*](#nt:noptr-abstract-declarator "9.3.2Type names[dcl.name]")opt [*parameters-and-qualifiers*](dcl.decl.general#nt:parameters-and-qualifiers "9.3.1General[dcl.decl.general]")
[*noptr-abstract-declarator*](#nt:noptr-abstract-declarator "9.3.2Type names[dcl.name]")opt [ [*constant-expression*](expr.const#nt:constant-expression "7.7Constant expressions[expr.const]")opt ] [*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1Attribute syntax and semantics[dcl.attr.grammar]")opt
( [*ptr-abstract-declarator*](#nt:ptr-abstract-declarator "9.3.2Type names[dcl.name]") )
[abstract-pack-declarator:](#nt:abstract-pack-declarator "9.3.2Type names[dcl.name]")
[*noptr-abstract-pack-declarator*](#nt:noptr-abstract-pack-declarator "9.3.2Type names[dcl.name]")
[*ptr-operator*](dcl.decl.general#nt:ptr-operator "9.3.1General[dcl.decl.general]") [*abstract-pack-declarator*](#nt:abstract-pack-declarator "9.3.2Type names[dcl.name]")
[noptr-abstract-pack-declarator:](#nt:noptr-abstract-pack-declarator "9.3.2Type names[dcl.name]")
[*noptr-abstract-pack-declarator*](#nt:noptr-abstract-pack-declarator "9.3.2Type names[dcl.name]") [*parameters-and-qualifiers*](dcl.decl.general#nt:parameters-and-qualifiers "9.3.1General[dcl.decl.general]")
...
It is possible to identify uniquely the location in the[*abstract-declarator*](#nt:abstract-declarator "9.3.2Type 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.4The typedef specifier[dcl.typedef]"),
which is introduced by a typedef declaration
or [*alias-declaration*](dcl.pre#nt:alias-declaration "9.1Preamble[dcl.pre]") ([[dcl.typedef]](dcl.typedef "9.2.4The typedef specifier"))[.](#2.sentence-1)
— *end note*]