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

45 lines
1.7 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.

[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.2Type 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.7Constant expressions"))[.](#2.sentence-2)
The [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4The typedef specifier[dcl.typedef]") std::size_t is declared in the standard header[<cstddef>](cstddef.syn#header:%3ccstddef%3e "17.2.1Header <cstddef> synopsis[cstddef.syn]") ([[cstddef.syn]](cstddef.syn "17.2.1Header <cstddef> synopsis"), [[support.types.layout]](support.types.layout "17.2.4Sizes, 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)