From Jason Turner

[basic.compound]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp5xadibkj/{from.md → to.md} +70 -32
tmp/tmp5xadibkj/{from.md → to.md} RENAMED
@@ -3,12 +3,12 @@
3
  Compound types can be constructed in the following ways:
4
 
5
  - *arrays* of objects of a given type,  [[dcl.array]];
6
  - *functions*, which have parameters of given types and return `void` or
7
  references or objects of a given type,  [[dcl.fct]];
8
- - *pointers* to `void` or objects or functions (including static members
9
- of classes) of a given type,  [[dcl.ptr]];
10
  - *references* to objects or functions of a given type,  [[dcl.ref]].
11
  There are two types of references:
12
  - *lvalue reference*
13
  - *rvalue reference*
14
  - *classes* containing a sequence of objects of various types (Clause 
@@ -19,50 +19,88 @@ Compound types can be constructed in the following ways:
19
  - *unions*, which are classes capable of containing objects of different
20
  types at different times,  [[class.union]];
21
  - *enumerations*, which comprise a set of named constant values. Each
22
  distinct enumeration constitutes a different *enumerated type*, 
23
  [[dcl.enum]];
24
- - *pointers to non-static* [^28] *class members*, which identify members
25
  of a given type within objects of a given class,  [[dcl.mptr]].
26
 
27
  These methods of constructing types can be applied recursively;
28
  restrictions are mentioned in  [[dcl.ptr]], [[dcl.array]], [[dcl.fct]],
29
  and  [[dcl.ref]]. Constructing a type such that the number of bytes in
30
  its object representation exceeds the maximum value representable in the
31
  type `std::size_t` ([[support.types]]) is ill-formed.
32
 
33
- The type of a pointer to `void` or a pointer to an object type is called
34
- an *object pointer type*. A pointer to `void` does not have a
35
- pointer-to-object type, however, because `void` is not an object type.
 
 
 
36
  The type of a pointer that can designate a function is called a
37
  *function pointer type*. A pointer to objects of type `T` is referred to
38
- as a “pointer to `T`. a pointer to an object of type `int` is referred
39
- to as “pointer to `int` ” and a pointer to an object of class `X` is
40
- called a pointer to `X`.” Except for pointers to static members, text
41
- referring to “pointersdoes not apply to pointers to members. Pointers
42
- to incomplete types are allowed although there are restrictions on what
43
- can be done with them ([[basic.align]]). A valid value of an object
44
- pointer type represents either the address of a byte in memory (
45
- [[intro.memory]]) or a null pointer ([[conv.ptr]]). If an object of
46
- type `T` is located at an address `A`, a pointer of type *cv* `T*` whose
47
- value is the address `A` is said to *point to* that object, regardless
48
- of how the value was obtained. For instance, the address one past the
49
- end of an array ([[expr.add]]) would be considered to point to an
50
- unrelated object of the array’s element type that might be located at
51
- that address. There are further restrictions on pointers to objects with
52
- dynamic storage duration; see  [[basic.stc.dynamic.safety]]. The value
53
- representation of pointer types is *implementation-defined*. Pointers to
54
- cv-qualified and cv-unqualified versions ([[basic.type.qualifier]]) of
55
- layout-compatible types shall have the same value representation and
56
- alignment requirements ([[basic.align]]). Pointers to over-aligned
57
- types ([[basic.align]]) have no special representation, but their range
58
- of valid values is restricted by the extended alignment requirement.
59
- This International Standard specifies only two ways of obtaining such a
60
- pointer: taking the address of a valid object with an over-aligned type,
61
- and using one of the runtime pointer alignment functions. An
62
- implementation may provide other means of obtaining a valid pointer
63
- value for an over-aligned type.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
 
65
  A pointer to cv-qualified ([[basic.type.qualifier]]) or cv-unqualified
66
  `void` can be used to point to objects of unknown type. Such a pointer
67
  shall be able to hold any object pointer. An object of type cv `void*`
68
  shall have the same representation and alignment requirements as
 
3
  Compound types can be constructed in the following ways:
4
 
5
  - *arrays* of objects of a given type,  [[dcl.array]];
6
  - *functions*, which have parameters of given types and return `void` or
7
  references or objects of a given type,  [[dcl.fct]];
8
+ - *pointers* to cv `void` or objects or functions (including static
9
+ members of classes) of a given type,  [[dcl.ptr]];
10
  - *references* to objects or functions of a given type,  [[dcl.ref]].
11
  There are two types of references:
12
  - *lvalue reference*
13
  - *rvalue reference*
14
  - *classes* containing a sequence of objects of various types (Clause 
 
19
  - *unions*, which are classes capable of containing objects of different
20
  types at different times,  [[class.union]];
21
  - *enumerations*, which comprise a set of named constant values. Each
22
  distinct enumeration constitutes a different *enumerated type*, 
23
  [[dcl.enum]];
24
+ - *pointers to non-static class members*, [^28] which identify members
25
  of a given type within objects of a given class,  [[dcl.mptr]].
26
 
27
  These methods of constructing types can be applied recursively;
28
  restrictions are mentioned in  [[dcl.ptr]], [[dcl.array]], [[dcl.fct]],
29
  and  [[dcl.ref]]. Constructing a type such that the number of bytes in
30
  its object representation exceeds the maximum value representable in the
31
  type `std::size_t` ([[support.types]]) is ill-formed.
32
 
33
+ The type of a pointer to cv `void` or a pointer to an object type is
34
+ called an *object pointer type*.
35
+
36
+ [*Note 1*: A pointer to `void` does not have a pointer-to-object type,
37
+ however, because `void` is not an object type. — *end note*]
38
+
39
  The type of a pointer that can designate a function is called a
40
  *function pointer type*. A pointer to objects of type `T` is referred to
41
+ as a “pointer to `T`”.
42
+
43
+ [*Example 1*: A pointer to an object of type `int` is referred to as
44
+ “pointer to `int`and a pointer to an object of class `X` is called a
45
+ “pointer to `X`”. *end example*]
46
+
47
+ Except for pointers to static members, text referring to “pointers” does
48
+ not apply to pointers to members. Pointers to incomplete types are
49
+ allowed although there are restrictions on what can be done with them (
50
+ [[basic.align]]). Every value of pointer type is one of the following:
51
+
52
+ - a *pointer to* an object or function (the pointer is said to *point*
53
+ to the object or function), or
54
+ - a *pointer past the end of* an object ([[expr.add]]), or
55
+ - the *null pointer value* ([[conv.ptr]]) for that type, or
56
+ - an *invalid pointer value*.
57
+
58
+ A value of a pointer type that is a pointer to or past the end of an
59
+ object *represents the address* of the first byte in memory (
60
+ [[intro.memory]]) occupied by the object [^29] or the first byte in
61
+ memory after the end of the storage occupied by the object,
62
+ respectively.
63
+
64
+ [*Note 2*: A pointer past the end of an object ([[expr.add]]) is not
65
+ considered to point to an unrelated object of the object’s type that
66
+ might be located at that address. A pointer value becomes invalid when
67
+ the storage it denotes reaches the end of its storage duration; see
68
+ [[basic.stc]]. — *end note*]
69
+
70
+ For purposes of pointer arithmetic ([[expr.add]]) and comparison (
71
+ [[expr.rel]], [[expr.eq]]), a pointer past the end of the last element
72
+ of an array `x` of n elements is considered to be equivalent to a
73
+ pointer to a hypothetical element `x[n]`. The value representation of
74
+ pointer types is *implementation-defined*. Pointers to layout-compatible
75
+ types shall have the same value representation and alignment
76
+ requirements ([[basic.align]]).
77
+
78
+ [*Note 3*: Pointers to over-aligned types ([[basic.align]]) have no
79
+ special representation, but their range of valid values is restricted by
80
+ the extended alignment requirement. — *end note*]
81
+
82
+ Two objects *a* and *b* are *pointer-interconvertible* if:
83
+
84
+ - they are the same object, or
85
+ - one is a standard-layout union object and the other is a non-static
86
+ data member of that object ([[class.union]]), or
87
+ - one is a standard-layout class object and the other is the first
88
+ non-static data member of that object, or, if the object has no
89
+ non-static data members, the first base class subobject of that
90
+ object ([[class.mem]]), or
91
+ - there exists an object *c* such that *a* and *c* are
92
+ pointer-interconvertible, and *c* and *b* are
93
+ pointer-interconvertible.
94
+
95
+ If two objects are pointer-interconvertible, then they have the same
96
+ address, and it is possible to obtain a pointer to one from a pointer to
97
+ the other via a `reinterpret_cast` ([[expr.reinterpret.cast]]).
98
+
99
+ [*Note 4*: An array object and its first element are not
100
+ pointer-interconvertible, even though they have the same
101
+ address. — *end note*]
102
 
103
  A pointer to cv-qualified ([[basic.type.qualifier]]) or cv-unqualified
104
  `void` can be used to point to objects of unknown type. Such a pointer
105
  shall be able to hold any object pointer. An object of type cv `void*`
106
  shall have the same representation and alignment requirements as