From Jason Turner

[conv.qual]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp6938rdkb/{from.md → to.md} +34 -24
tmp/tmp6938rdkb/{from.md → to.md} RENAMED
@@ -1,44 +1,49 @@
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ᵢ”, or “array 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';
@@ -49,15 +54,20 @@ int main() {
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
 
 
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]], and
7
+ each Pᵢ is “pointer to” [[dcl.ptr]], “pointer to member of class Cᵢ of
8
+ type” [[dcl.mptr]], “array of Nᵢ”, or “array of unknown bound of”
9
+ [[dcl.array]]. If Pᵢ designates an array, the cv-qualifiers cvᵢ₊₁ on the
10
+ element type are also taken as the cv-qualifiers cvᵢ of the array.
 
11
 
12
+ [*Example 1*: The type denoted by the *type-id* `const int **` has
13
+ three cv-decompositions, taking `U` as “`int`”, as “pointer to
14
+ `const int`”, and as “pointer to 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 `T1` and `T2` are *similar* if they have cv-decompositions
22
+ with the same n such that corresponding Pᵢ components are either the
23
+ same or one is “array of Nᵢ” and the other is “array of unknown bound
24
+ of”, and the types denoted by `U` are the same.
25
 
26
+ The *cv-combined type* of two types `T1` and `T2` is the type `T3`
27
+ similar to `T1` whose cv-decomposition is such that:
 
28
 
29
+ - for every i > 0, cv³ᵢ is the union of cv¹ᵢ and cv²ᵢ;
30
+ - if either P¹ᵢ or P²ᵢ is “array of unknown bound of”, P³ᵢ is “array of
31
+ unknown bound of”, otherwise it is P¹ᵢ;
32
+ - if the resulting cv³is different from cv¹ᵢ or cv²ᵢ, or the resulting
33
+ P³ᵢ is different from P¹ᵢ or P²ᵢ, then `const` is added to every cv³ₖ
34
+ for 0 < k < i.
35
+
36
+ where cvʲᵢ and Pʲᵢ are the components of the cv-decomposition of `T`j. A
37
+ prvalue of type `T1` can be converted to type `T2` if the cv-combined
38
+ type of `T1` and `T2` is `T2`.
39
 
40
  [*Note 1*:
41
 
42
  If a program could assign a pointer of type `T**` to a pointer of type
43
  `const` `T**` (that is, if line \#1 below were allowed), a program could
44
+ inadvertently modify a const object (as it is done on line \#2). For
45
  example,
46
 
47
  ``` cpp
48
  int main() {
49
  const char c = 'c';
 
54
  }
55
  ```
56
 
57
  — *end note*]
58
 
59
+ [*Note 2*: Given similar types `T1` and `T2`, this construction ensures
60
+ that both can be converted to the cv-combined type of `T1` and
61
+ `T2`. — *end note*]
62
+
63
+ [*Note 3*: A prvalue of type “pointer to *cv1* `T`” can be converted to
64
  a prvalue of type “pointer to *cv2* `T`” if “*cv2* `T`” is more
65
  cv-qualified than “*cv1* `T`”. A prvalue of type “pointer to member of
66
  `X` of type *cv1* `T`” can be converted to a prvalue of type “pointer to
67
  member of `X` of type *cv2* `T`” if “*cv2* `T`” is more cv-qualified
68
  than “*cv1* `T`”. — *end note*]
69
 
70
+ [*Note 4*: Function types (including those used in
71
+ pointer-to-member-function types) are never cv-qualified
72
+ [[dcl.fct]]. — *end note*]
73