tmp/tmp0waxh7dl/{from.md → to.md}
RENAMED
|
@@ -1,18 +1,22 @@
|
|
| 1 |
### Pointers to members <a id="dcl.mptr">[[dcl.mptr]]</a>
|
| 2 |
|
| 3 |
In a declaration `T` `D` where `D` has the form
|
| 4 |
|
| 5 |
``` bnf
|
| 6 |
-
nested-name-specifier '*' attribute-specifier-seqₒₚₜ cv-qualifier-seqₒₚₜ D1
|
| 7 |
```
|
| 8 |
|
| 9 |
and the *nested-name-specifier* denotes a class, and the type of the
|
| 10 |
-
identifier in the declaration `T` `D1` is
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
``` cpp
|
| 16 |
struct X {
|
| 17 |
void f(int);
|
| 18 |
int a;
|
|
@@ -34,20 +38,20 @@ declaration of `pmc` is well-formed even though `Y` is an incomplete
|
|
| 34 |
type. `pmi` and `pmf` can be used like this:
|
| 35 |
|
| 36 |
``` cpp
|
| 37 |
X obj;
|
| 38 |
// ...
|
| 39 |
-
obj.*pmi = 7; // assign 7 to an integer
|
| 40 |
-
|
| 41 |
-
(obj.*pmf)(7); // call a function member of obj
|
| 42 |
-
// with the argument 7
|
| 43 |
```
|
| 44 |
|
|
|
|
|
|
|
| 45 |
A pointer to member shall not point to a static member of a class (
|
| 46 |
-
[[class.static]]), a member with reference type, or “
|
| 47 |
|
| 48 |
-
See also [[expr.unary]] and [[expr.mptr.oper]]. The type
|
| 49 |
-
member” is distinct from the type “pointer”, that is, a
|
| 50 |
-
member is declared only by the pointer to member declarator
|
| 51 |
-
never by the pointer declarator syntax. There is no
|
| 52 |
-
“reference-to-member” type in C++.
|
| 53 |
|
|
|
|
| 1 |
### Pointers to members <a id="dcl.mptr">[[dcl.mptr]]</a>
|
| 2 |
|
| 3 |
In a declaration `T` `D` where `D` has the form
|
| 4 |
|
| 5 |
``` bnf
|
| 6 |
+
nested-name-specifier '*' attribute-specifier-seqₒₚₜ cv-qualifier-seqₒₚₜ 'D1'
|
| 7 |
```
|
| 8 |
|
| 9 |
and the *nested-name-specifier* denotes a class, and the type of the
|
| 10 |
+
identifier in the declaration `T` `D1` is
|
| 11 |
+
“*derived-declarator-type-list* `T`”, then the type of the identifier of
|
| 12 |
+
`D` is “*derived-declarator-type-list* *cv-qualifier-seq* pointer to
|
| 13 |
+
member of class *nested-name-specifier* of type `T`”. The optional
|
| 14 |
+
*attribute-specifier-seq* ([[dcl.attr.grammar]]) appertains to the
|
| 15 |
+
pointer-to-member.
|
| 16 |
+
|
| 17 |
+
[*Example 1*:
|
| 18 |
|
| 19 |
``` cpp
|
| 20 |
struct X {
|
| 21 |
void f(int);
|
| 22 |
int a;
|
|
|
|
| 38 |
type. `pmi` and `pmf` can be used like this:
|
| 39 |
|
| 40 |
``` cpp
|
| 41 |
X obj;
|
| 42 |
// ...
|
| 43 |
+
obj.*pmi = 7; // assign 7 to an integer member of obj
|
| 44 |
+
(obj.*pmf)(7); // call a function member of obj with the argument 7
|
|
|
|
|
|
|
| 45 |
```
|
| 46 |
|
| 47 |
+
— *end example*]
|
| 48 |
+
|
| 49 |
A pointer to member shall not point to a static member of a class (
|
| 50 |
+
[[class.static]]), a member with reference type, or “cv `void`”.
|
| 51 |
|
| 52 |
+
[*Note 1*: See also [[expr.unary]] and [[expr.mptr.oper]]. The type
|
| 53 |
+
“pointer to member” is distinct from the type “pointer”, that is, a
|
| 54 |
+
pointer to member is declared only by the pointer to member declarator
|
| 55 |
+
syntax, and never by the pointer declarator syntax. There is no
|
| 56 |
+
“reference-to-member” type in C++. — *end note*]
|
| 57 |
|