From Jason Turner

[expr.sizeof]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp2juqqldc/{from.md → to.md} +24 -14
tmp/tmp2juqqldc/{from.md → to.md} RENAMED
@@ -2,21 +2,23 @@
2
 
3
  The `sizeof` operator yields the number of bytes in the object
4
  representation of its operand. The operand is either an expression,
5
  which is an unevaluated operand (Clause  [[expr]]), or a parenthesized
6
  *type-id*. The `sizeof` operator shall not be applied to an expression
7
- that has function or incomplete type, to an enumeration type whose
8
- underlying type is not fixed before all its enumerators have been
9
- declared, to the parenthesized name of such types, or to a glvalue that
10
- designates a bit-field. `sizeof(char)`, `sizeof(signed char)` and
11
- `sizeof(unsigned char)` are `1`. The result of `sizeof` applied to any
12
- other fundamental type ([[basic.fundamental]]) is
13
- *implementation-defined*. in particular, `sizeof(bool)`,
14
- `sizeof(char16_t)`, `sizeof(char32_t)`, and `sizeof(wchar_t)` are
15
- implementation-defined.[^16] See  [[intro.memory]] for the definition of
16
- *byte* and  [[basic.types]] for the definition of *object
17
- representation*.
 
 
18
 
19
  When applied to a reference or a reference type, the result is the size
20
  of the referenced type. When applied to a class, the result is the
21
  number of bytes in an object of that class including any padding
22
  required for placing objects of that type in an array. The size of a
@@ -29,23 +31,31 @@ number of bytes in the array. This implies that the size of an array of
29
  The `sizeof` operator can be applied to a pointer to a function, but
30
  shall not be applied directly to a function.
31
 
32
  The lvalue-to-rvalue ([[conv.lval]]), array-to-pointer (
33
  [[conv.array]]), and function-to-pointer ([[conv.func]]) standard
34
- conversions are not applied to the operand of `sizeof`.
 
 
35
 
36
  The identifier in a `sizeof...` expression shall name a parameter pack.
37
  The `sizeof...` operator yields the number of arguments provided for the
38
  parameter pack *identifier*. A `sizeof...` expression is a pack
39
  expansion ([[temp.variadic]]).
40
 
 
 
41
  ``` cpp
42
  template<class... Types>
43
  struct count {
44
  static const std::size_t value = sizeof...(Types);
45
  };
46
  ```
47
 
 
 
48
  The result of `sizeof` and `sizeof...` is a constant of type
49
- `std::size_t`. `std::size_t` is defined in the standard header
50
- `<cstddef>` ([[support.types]]).
 
 
51
 
 
2
 
3
  The `sizeof` operator yields the number of bytes in the object
4
  representation of its operand. The operand is either an expression,
5
  which is an unevaluated operand (Clause  [[expr]]), or a parenthesized
6
  *type-id*. The `sizeof` operator shall not be applied to an expression
7
+ that has function or incomplete type, to the parenthesized name of such
8
+ types, or to a glvalue that designates a bit-field. `sizeof(char)`,
9
+ `sizeof(signed char)` and `sizeof(unsigned char)` are `1`. The result of
10
+ `sizeof` applied to any other fundamental type ([[basic.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] *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 or a reference type, the result is the size
22
  of the referenced type. When applied to a class, the result is the
23
  number of bytes in an object of that class including any padding
24
  required for placing objects of that type in an array. The size of a
 
31
  The `sizeof` operator can be applied to a pointer to a function, but
32
  shall not be applied directly to a function.
33
 
34
  The lvalue-to-rvalue ([[conv.lval]]), array-to-pointer (
35
  [[conv.array]]), and function-to-pointer ([[conv.func]]) standard
36
+ conversions are not applied to the operand of `sizeof`. If the operand
37
+ is a prvalue, the temporary materialization conversion ([[conv.rval]])
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>
49
  struct count {
50
  static const std::size_t value = sizeof...(Types);
51
  };
52
  ```
53
 
54
+ — *end example*]
55
+
56
  The result of `sizeof` and `sizeof...` is a constant of type
57
+ `std::size_t`.
58
+
59
+ [*Note 3*: `std::size_t` is defined in the standard header
60
+ `<cstddef>` ([[cstddef.syn]], [[support.types.layout]]). — *end note*]
61