45 lines
1.7 KiB
Markdown
45 lines
1.7 KiB
Markdown
[expr.alignof]
|
||
|
||
# 7 Expressions [[expr]](./#expr)
|
||
|
||
## 7.6 Compound expressions [[expr.compound]](expr.compound#expr.alignof)
|
||
|
||
### 7.6.2 Unary expressions [[expr.unary]](expr.unary#expr.alignof)
|
||
|
||
#### 7.6.2.6 Alignof [expr.alignof]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L5700)
|
||
|
||
An alignof expression yields the alignment requirement
|
||
of its operand type[.](#1.sentence-1)
|
||
|
||
The operand shall be a [*type-id*](dcl.name#nt:type-id "9.3.2 Type names [dcl.name]") representing a complete object type, or an array thereof, or a reference
|
||
to one of those types[.](#1.sentence-2)
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L5708)
|
||
|
||
The result is a prvalue of type std::size_t[.](#2.sentence-1)
|
||
|
||
[*Note [1](#note-1)*:
|
||
|
||
An alignof expression
|
||
is an integral constant expression ([[expr.const]](expr.const "7.7 Constant expressions"))[.](#2.sentence-2)
|
||
|
||
The [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4 The typedef specifier [dcl.typedef]") std::size_t is declared in the standard header[<cstddef>](cstddef.syn#header:%3ccstddef%3e "17.2.1 Header <cstddef> synopsis [cstddef.syn]") ([[cstddef.syn]](cstddef.syn "17.2.1 Header <cstddef> synopsis"), [[support.types.layout]](support.types.layout "17.2.4 Sizes, alignments, and offsets"))[.](#2.sentence-3)
|
||
|
||
â *end note*]
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L5717)
|
||
|
||
When alignof is applied to a reference type, the result
|
||
is the alignment of the referenced type[.](#3.sentence-1)
|
||
|
||
When alignof is applied to an array type, the result is the alignment of the
|
||
element type[.](#3.sentence-2)
|