From Jason Turner

[conv.qual]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmphglon4xf/{from.md → to.md} +43 -27
tmp/tmphglon4xf/{from.md → to.md} RENAMED
@@ -1,25 +1,45 @@
1
  ## Qualification conversions <a id="conv.qual">[[conv.qual]]</a>
2
 
3
- A prvalue of type “pointer to *cv1* `T` can be converted to a prvalue
4
- of type “pointer to *cv2* `T` if “*cv2* `T`” is more cv-qualified than
5
- “*cv1* `T`”.
6
 
7
- A prvalue of type “pointer to member of `X` of type *cv1* `T`” can be
8
- converted to a prvalue of type “pointer to member of `X` of type *cv2*
9
- `T`” if “*cv2* `T`is more cv-qualified than*cv1* `T`”.
 
 
 
10
 
11
- Function types (including those used in pointer to member function
12
- types) are never cv-qualified ([[dcl.fct]]).
 
13
 
14
- A conversion can add cv-qualifiers at levels other than the first in
15
- multi-level pointers, subject to the following rules:[^4]
 
16
 
17
- if a program could assign a pointer of type `T**` to a pointer of type
18
- `const` `T**` (that is, if line `#1` below were allowed), a program
19
- could inadvertently modify a `const` object (as it is done on line
20
- `#2`). For example,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  ``` cpp
23
  int main() {
24
  const char c = 'c';
25
  char* pc;
@@ -27,21 +47,17 @@ int main() {
27
  *pcc = &c;
28
  *pc = 'C'; // #2: modifies a const object
29
  }
30
  ```
31
 
32
- A *multi-level* pointer to member type, or a *multi-level mixed* pointer
33
- and pointer to member type has the form:
34
 
35
- where Pᵢ is either a pointer or pointer to member and where *T* is not a
36
- pointer type or pointer to member type.
 
 
 
 
37
 
38
- Two multi-level pointer to member types or two multi-level mixed pointer
39
- and pointer to member types T1 and T2 are *similar* if there exists a
40
- type *T* and integer n > 0 such that:
41
-
42
- and
43
-
44
- For similar multi-level pointer to member types and similar multi-level
45
- mixed pointer and pointer to member types, the rules for adding
46
- cv-qualifiers are the same as those used for similar pointer types.
47
 
 
1
  ## Qualification conversions <a id="conv.qual">[[conv.qual]]</a>
2
 
3
+ A *cv-decomposition* of a type `T` is a sequence of cvᵢ and Pᵢ such that
4
+ `T` is
 
5
 
6
+ where each cvᵢ is a set of cv-qualifiers ([[basic.type.qualifier]]),
7
+ and each Pᵢ is “pointer to” ([[dcl.ptr]]), “pointer to member of class
8
+ Cᵢ of type ([[dcl.mptr]]), “array of Nᵢ”, orarray of unknown bound
9
+ of” ([[dcl.array]]). If Pᵢ designates an array, the cv-qualifiers cvᵢ₊₁
10
+ on the element type are also taken as the cv-qualifiers cvᵢ of the
11
+ array.
12
 
13
+ [*Example 1*: The type denoted by the *type-id* `const int **` has two
14
+ cv-decompositions, taking `U` as “`int`” and as “pointer to
15
+ `const int`”. — *end example*]
16
 
17
+ The n-tuple of cv-qualifiers after the first one in the longest
18
+ cv-decomposition of `T`, that is, cv₁, cv₂, …, cvₙ, is called the
19
+ *cv-qualification signature* of `T`.
20
 
21
+ Two types `T₁` and `T` are *similar* if they have cv-decompositions
22
+ with the same n such that corresponding Pᵢ components are the same and
23
+ the types denoted by `U` are the same.
24
+
25
+ A prvalue expression of type `T₁` can be converted to type `T₂` if the
26
+ following conditions are satisfied, where cvᵢʲ denotes the cv-qualifiers
27
+ in the cv-qualification signature of `Tⱼ`: [^4]
28
+
29
+ - `T₁` and `T₂` are similar.
30
+ - For every i > 0, if `const` is in cvᵢ¹ then `const` is in cvᵢ², and
31
+ similarly for `volatile`.
32
+ - If the cvᵢ¹ and cvᵢ² are different, then `const` is in every cvₖ² for
33
+ 0 < k < i.
34
+
35
+ [*Note 1*:
36
+
37
+ If a program could assign a pointer of type `T**` to a pointer of type
38
+ `const` `T**` (that is, if line \#1 below were allowed), a program could
39
+ inadvertently modify a `const` object (as it is done on line \#2). For
40
+ example,
41
 
42
  ``` cpp
43
  int main() {
44
  const char c = 'c';
45
  char* pc;
 
47
  *pcc = &c;
48
  *pc = 'C'; // #2: modifies a const object
49
  }
50
  ```
51
 
52
+ *end note*]
 
53
 
54
+ [*Note 2*: A prvalue of type pointer to *cv1* `T`” can be converted to
55
+ a prvalue of type “pointer to *cv2* `T`” if “*cv2* `T`” is more
56
+ cv-qualified than “*cv1* `T`”. A prvalue of type “pointer to member of
57
+ `X` of type *cv1* `T`” can be converted to a prvalue of type “pointer to
58
+ member of `X` of type *cv2* `T`” if “*cv2* `T`” is more cv-qualified
59
+ than “*cv1* `T`”. — *end note*]
60
 
61
+ [*Note 3*: Function types (including those used in pointer to member
62
+ function types) are never cv-qualified ([[dcl.fct]]). *end note*]
 
 
 
 
 
 
 
63