From Jason Turner

[expr.const.cast]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpr15oeufr/{from.md → to.md} +16 -10
tmp/tmpr15oeufr/{from.md → to.md} RENAMED
@@ -9,17 +9,17 @@ otherwise, the result is a prvalue and the lvalue-to-rvalue
9
  Conversions that can be performed explicitly using `const_cast` are
10
  listed below. No other conversion shall be performed explicitly using
11
  `const_cast`.
12
 
13
  [*Note 1*: Subject to the restrictions in this subclause, an expression
14
- may be cast to its own type using a `const_cast`
15
  operator. — *end note*]
16
 
17
  For two similar types `T1` and `T2` [[conv.qual]], a prvalue of type
18
  `T1` may be explicitly converted to the type `T2` using a `const_cast`
19
- if, considering the cv-decompositions of both types, each P¹ᵢ is the
20
- same as P²ᵢ for all i. The result of a `const_cast` refers to the
21
  original entity.
22
 
23
  [*Example 1*:
24
 
25
  ``` cpp
@@ -52,29 +52,35 @@ materialization conversion [[conv.rval]] otherwise.
52
  A null pointer value [[basic.compound]] is converted to the null pointer
53
  value of the destination type. The null member pointer value
54
  [[conv.mem]] is converted to the null member pointer value of the
55
  destination type.
56
 
57
- [*Note 2*: Depending on the type of the object, a write operation
58
- through the pointer, lvalue or pointer to data member resulting from a
59
- `const_cast` that casts away a const-qualifier[^20] may produce
60
- undefined behavior [[dcl.type.cv]]. *end note*]
 
 
 
 
 
61
 
62
  A conversion from a type `T1` to a type `T2` *casts away constness* if
63
- `T1` and `T2` are different, there is a cv-decomposition [[conv.qual]]
64
- of `T1` yielding *n* such that `T2` has a cv-decomposition of the form
 
65
 
66
  and there is no qualification conversion that converts `T1` to
67
 
68
  Casting from an lvalue of type `T1` to an lvalue of type `T2` using an
69
  lvalue reference cast or casting from an expression of type `T1` to an
70
  xvalue of type `T2` using an rvalue reference cast casts away constness
71
  if a cast from a prvalue of type “pointer to `T1`” to the type “pointer
72
  to `T2`” casts away constness.
73
 
74
  [*Note 3*: Some conversions which involve only changes in
75
- cv-qualification cannot be done using `const_cast.` For instance,
76
  conversions between pointers to functions are not covered because such
77
  conversions lead to values whose use causes undefined behavior. For the
78
  same reasons, conversions between pointers to member functions, and in
79
  particular, the conversion from a pointer to a const member function to
80
  a pointer to a non-const member function, are not
 
9
  Conversions that can be performed explicitly using `const_cast` are
10
  listed below. No other conversion shall be performed explicitly using
11
  `const_cast`.
12
 
13
  [*Note 1*: Subject to the restrictions in this subclause, an expression
14
+ can be cast to its own type using a `const_cast`
15
  operator. — *end note*]
16
 
17
  For two similar types `T1` and `T2` [[conv.qual]], a prvalue of type
18
  `T1` may be explicitly converted to the type `T2` using a `const_cast`
19
+ if, considering the qualification-decompositions of both types, each P¹ᵢ
20
+ is the same as P²ᵢ for all i. The result of a `const_cast` refers to the
21
  original entity.
22
 
23
  [*Example 1*:
24
 
25
  ``` cpp
 
52
  A null pointer value [[basic.compound]] is converted to the null pointer
53
  value of the destination type. The null member pointer value
54
  [[conv.mem]] is converted to the null member pointer value of the
55
  destination type.
56
 
57
+ [*Note 2*:
58
+
59
+ Depending on the type of the object, a write operation through the
60
+ pointer, lvalue or pointer to data member resulting from a `const_cast`
61
+ that casts away a const-qualifier[^20]
62
+
63
+ can produce undefined behavior [[dcl.type.cv]].
64
+
65
+ — *end note*]
66
 
67
  A conversion from a type `T1` to a type `T2` *casts away constness* if
68
+ `T1` and `T2` are different, there is a qualification-decomposition
69
+ [[conv.qual]] of `T1` yielding *n* such that `T2` has a
70
+ qualification-decomposition of the form
71
 
72
  and there is no qualification conversion that converts `T1` to
73
 
74
  Casting from an lvalue of type `T1` to an lvalue of type `T2` using an
75
  lvalue reference cast or casting from an expression of type `T1` to an
76
  xvalue of type `T2` using an rvalue reference cast casts away constness
77
  if a cast from a prvalue of type “pointer to `T1`” to the type “pointer
78
  to `T2`” casts away constness.
79
 
80
  [*Note 3*: Some conversions which involve only changes in
81
+ cv-qualification cannot be done using `const_cast`. For instance,
82
  conversions between pointers to functions are not covered because such
83
  conversions lead to values whose use causes undefined behavior. For the
84
  same reasons, conversions between pointers to member functions, and in
85
  particular, the conversion from a pointer to a const member function to
86
  a pointer to a non-const member function, are not