tmp/tmpkat7b2xt/{from.md → to.md}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
-
## Pointer-to-member operators <a id="expr.mptr.oper">[[expr.mptr.oper]]</a>
|
| 2 |
|
| 3 |
The pointer-to-member operators `->*` and `.*` group left-to-right.
|
| 4 |
|
| 5 |
``` bnf
|
| 6 |
pm-expression:
|
|
@@ -24,30 +24,30 @@ converted into the equivalent form `(*(E1)).*E2`.
|
|
| 24 |
Abbreviating *pm-expression*`.*`*cast-expression* as `E1.*E2`, `E1` is
|
| 25 |
called the *object expression*. If the dynamic type of `E1` does not
|
| 26 |
contain the member to which `E2` refers, the behavior is undefined.
|
| 27 |
Otherwise, the expression `E1` is sequenced before the expression `E2`.
|
| 28 |
|
| 29 |
-
The restrictions on
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
|
| 34 |
[*Note 1*:
|
| 35 |
|
| 36 |
It is not possible to use a pointer to member that refers to a `mutable`
|
| 37 |
-
member to modify a
|
| 38 |
|
| 39 |
``` cpp
|
| 40 |
struct S {
|
| 41 |
S() : i(0) { }
|
| 42 |
mutable int i;
|
| 43 |
};
|
| 44 |
void f()
|
| 45 |
{
|
| 46 |
const S cs;
|
| 47 |
int S::* pm = &S::i; // pm refers to mutable member S::i
|
| 48 |
-
cs.*pm = 88; //
|
| 49 |
}
|
| 50 |
```
|
| 51 |
|
| 52 |
— *end note*]
|
| 53 |
|
|
@@ -64,15 +64,16 @@ calls the member function denoted by `ptr_to_mfct` for the object
|
|
| 64 |
pointed to by `ptr_to_obj`.
|
| 65 |
|
| 66 |
— *end example*]
|
| 67 |
|
| 68 |
In a `.*` expression whose object expression is an rvalue, the program
|
| 69 |
-
is ill-formed if the second operand is a pointer to member function
|
| 70 |
-
*ref-qualifier* `&`
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
|
|
|
| 78 |
|
|
|
|
| 1 |
+
### Pointer-to-member operators <a id="expr.mptr.oper">[[expr.mptr.oper]]</a>
|
| 2 |
|
| 3 |
The pointer-to-member operators `->*` and `.*` group left-to-right.
|
| 4 |
|
| 5 |
``` bnf
|
| 6 |
pm-expression:
|
|
|
|
| 24 |
Abbreviating *pm-expression*`.*`*cast-expression* as `E1.*E2`, `E1` is
|
| 25 |
called the *object expression*. If the dynamic type of `E1` does not
|
| 26 |
contain the member to which `E2` refers, the behavior is undefined.
|
| 27 |
Otherwise, the expression `E1` is sequenced before the expression `E2`.
|
| 28 |
|
| 29 |
+
The restrictions on cv-qualification, and the manner in which the
|
| 30 |
+
cv-qualifiers of the operands are combined to produce the cv-qualifiers
|
| 31 |
+
of the result, are the same as the rules for `E1.E2` given in
|
| 32 |
+
[[expr.ref]].
|
| 33 |
|
| 34 |
[*Note 1*:
|
| 35 |
|
| 36 |
It is not possible to use a pointer to member that refers to a `mutable`
|
| 37 |
+
member to modify a const class object. For example,
|
| 38 |
|
| 39 |
``` cpp
|
| 40 |
struct S {
|
| 41 |
S() : i(0) { }
|
| 42 |
mutable int i;
|
| 43 |
};
|
| 44 |
void f()
|
| 45 |
{
|
| 46 |
const S cs;
|
| 47 |
int S::* pm = &S::i; // pm refers to mutable member S::i
|
| 48 |
+
cs.*pm = 88; // error: cs is a const object
|
| 49 |
}
|
| 50 |
```
|
| 51 |
|
| 52 |
— *end note*]
|
| 53 |
|
|
|
|
| 64 |
pointed to by `ptr_to_obj`.
|
| 65 |
|
| 66 |
— *end example*]
|
| 67 |
|
| 68 |
In a `.*` expression whose object expression is an rvalue, the program
|
| 69 |
+
is ill-formed if the second operand is a pointer to member function
|
| 70 |
+
whose *ref-qualifier* is `&`, unless its *cv-qualifier-seq* is `const`.
|
| 71 |
+
In a `.*` expression whose object expression is an lvalue, the program
|
| 72 |
+
is ill-formed if the second operand is a pointer to member function
|
| 73 |
+
whose *ref-qualifier* is `&&`. The result of a `.*` expression whose
|
| 74 |
+
second operand is a pointer to a data member is an lvalue if the first
|
| 75 |
+
operand is an lvalue and an xvalue otherwise. The result of a `.*`
|
| 76 |
+
expression whose second operand is a pointer to a member function is a
|
| 77 |
+
prvalue. If the second operand is the null member pointer value
|
| 78 |
+
[[conv.mem]], the behavior is undefined.
|
| 79 |
|