tmp/tmp93f_zmsn/{from.md → to.md}
RENAMED
|
@@ -1,48 +1,43 @@
|
|
| 1 |
-
### Sizeof <a id="expr.sizeof">[[expr.sizeof]]</a>
|
| 2 |
|
| 3 |
-
The `sizeof` operator yields the number of bytes
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
*type-id*. The `sizeof` operator shall
|
| 7 |
-
that has function or incomplete type, to
|
| 8 |
-
types, or to a glvalue that designates a
|
| 9 |
-
|
| 10 |
-
`sizeof` applied to any other fundamental
|
| 11 |
-
is *implementation-defined*.
|
| 12 |
|
| 13 |
[*Note 1*: In particular, `sizeof(bool)`, `sizeof(char16_t)`,
|
| 14 |
`sizeof(char32_t)`, and `sizeof(wchar_t)` are
|
| 15 |
-
implementation-defined.[^
|
| 16 |
|
| 17 |
-
[*Note 2*: See [[intro.memory]] for the definition of
|
| 18 |
-
[[basic.types]] for the definition of
|
| 19 |
-
representation
|
| 20 |
|
| 21 |
-
When applied to a reference
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
*n* elements is *n* times the size of an element.
|
| 30 |
|
| 31 |
-
The
|
| 32 |
-
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
The
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
is applied.
|
| 39 |
-
|
| 40 |
-
The identifier in a `sizeof...` expression shall name a parameter pack.
|
| 41 |
-
The `sizeof...` operator yields the number of arguments provided for the
|
| 42 |
-
parameter pack *identifier*. A `sizeof...` expression is a pack
|
| 43 |
-
expansion ([[temp.variadic]]).
|
| 44 |
|
| 45 |
[*Example 1*:
|
| 46 |
|
| 47 |
``` cpp
|
| 48 |
template<class... Types>
|
|
@@ -51,11 +46,12 @@ struct count {
|
|
| 51 |
};
|
| 52 |
```
|
| 53 |
|
| 54 |
— *end example*]
|
| 55 |
|
| 56 |
-
The result of `sizeof` and `sizeof...` is a
|
| 57 |
`std::size_t`.
|
| 58 |
|
| 59 |
-
[*Note 3*:
|
|
|
|
| 60 |
`<cstddef>` ([[cstddef.syn]], [[support.types.layout]]). — *end note*]
|
| 61 |
|
|
|
|
| 1 |
+
#### Sizeof <a id="expr.sizeof">[[expr.sizeof]]</a>
|
| 2 |
|
| 3 |
+
The `sizeof` operator yields the number of bytes occupied by a
|
| 4 |
+
non-potentially-overlapping object of the type of its operand. The
|
| 5 |
+
operand is either an expression, which is an unevaluated operand
|
| 6 |
+
[[expr.prop]], or a parenthesized *type-id*. The `sizeof` operator shall
|
| 7 |
+
not be applied to an expression that has function or incomplete type, to
|
| 8 |
+
the parenthesized name of such types, or to a glvalue that designates a
|
| 9 |
+
bit-field. The result of `sizeof` applied to any of the narrow character
|
| 10 |
+
types is `1`. The result of `sizeof` applied to any other fundamental
|
| 11 |
+
type [[basic.fundamental]] is *implementation-defined*.
|
| 12 |
|
| 13 |
[*Note 1*: In particular, `sizeof(bool)`, `sizeof(char16_t)`,
|
| 14 |
`sizeof(char32_t)`, and `sizeof(wchar_t)` are
|
| 15 |
+
implementation-defined.[^21] — *end note*]
|
| 16 |
|
| 17 |
+
[*Note 2*: See [[intro.memory]] for the definition of byte and
|
| 18 |
+
[[basic.types]] for the definition of object
|
| 19 |
+
representation. — *end note*]
|
| 20 |
|
| 21 |
+
When applied to a reference type, the result is the size of the
|
| 22 |
+
referenced type. When applied to a class, the result is the number of
|
| 23 |
+
bytes in an object of that class including any padding required for
|
| 24 |
+
placing objects of that type in an array. The result of applying
|
| 25 |
+
`sizeof` to a potentially-overlapping subobject is the size of the type,
|
| 26 |
+
not the size of the subobject. [^22] When applied to an array, the
|
| 27 |
+
result is the total number of bytes in the array. This implies that the
|
| 28 |
+
size of an array of n elements is n times the size of an element.
|
|
|
|
| 29 |
|
| 30 |
+
The lvalue-to-rvalue [[conv.lval]], array-to-pointer [[conv.array]], and
|
| 31 |
+
function-to-pointer [[conv.func]] standard conversions are not applied
|
| 32 |
+
to the operand of `sizeof`. If the operand is a prvalue, the temporary
|
| 33 |
+
materialization conversion [[conv.rval]] is applied.
|
| 34 |
|
| 35 |
+
The identifier in a `sizeof...` expression shall name a pack. The
|
| 36 |
+
`sizeof...` operator yields the number of elements in the pack
|
| 37 |
+
[[temp.variadic]]. A `sizeof...` expression is a pack expansion
|
| 38 |
+
[[temp.variadic]].
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
[*Example 1*:
|
| 41 |
|
| 42 |
``` cpp
|
| 43 |
template<class... Types>
|
|
|
|
| 46 |
};
|
| 47 |
```
|
| 48 |
|
| 49 |
— *end example*]
|
| 50 |
|
| 51 |
+
The result of `sizeof` and `sizeof...` is a prvalue of type
|
| 52 |
`std::size_t`.
|
| 53 |
|
| 54 |
+
[*Note 3*: A `sizeof` expression is an integral constant expression
|
| 55 |
+
[[expr.const]]. The type `std::size_t` is defined in the standard header
|
| 56 |
`<cstddef>` ([[cstddef.syn]], [[support.types.layout]]). — *end note*]
|
| 57 |
|