tmp/tmpq5mdqxms/{from.md → to.md}
RENAMED
|
@@ -1,81 +1,91 @@
|
|
| 1 |
-
### Class member access <a id="expr.ref">[[expr.ref]]</a>
|
| 2 |
|
| 3 |
A postfix expression followed by a dot `.` or an arrow `->`, optionally
|
| 4 |
-
followed by the keyword `template`
|
| 5 |
-
|
| 6 |
-
before the dot or arrow is evaluated;[^
|
| 7 |
-
together with the *id-expression*, determines the result of
|
| 8 |
-
postfix expression.
|
| 9 |
-
|
| 10 |
-
For the first option (dot) the first expression shall be a glvalue
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
[*Note
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
after the `.` and `->` operators. — *end note*]
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
cv-qualifiers, as defined in [[basic.type.qualifier]].
|
| 32 |
|
| 33 |
If `E2` is declared to have type “reference to `T`”, then `E1.E2` is an
|
| 34 |
lvalue; the type of `E1.E2` is `T`. Otherwise, one of the following
|
| 35 |
rules applies.
|
| 36 |
|
| 37 |
- If `E2` is a static data member and the type of `E2` is `T`, then
|
| 38 |
`E1.E2` is an lvalue; the expression designates the named member of
|
| 39 |
the class. The type of `E1.E2` is `T`.
|
| 40 |
- If `E2` is a non-static data member and the type of `E1` is “*cq1 vq1*
|
| 41 |
`X`”, and the type of `E2` is “*cq2 vq2* `T`”, the expression
|
| 42 |
-
designates the
|
| 43 |
-
expression. If `E1` is an lvalue, then `E1.E2` is an
|
| 44 |
-
`E1.E2` is an xvalue. Let the notation *vq12* stand
|
| 45 |
-
*vq1* and *vq2*; that is, if *vq1* or *vq2* is
|
| 46 |
-
is `volatile`. Similarly, let the notation
|
| 47 |
-
“union” of *cq1* and *cq2*; that is, if *cq1* or
|
| 48 |
-
then *cq12* is `const`. If `E2` is declared to be a
|
| 49 |
-
then the type of `E1.E2` is “*vq12* `T`”. If `E2` is
|
| 50 |
-
be a `mutable` member, then the type of `E1.E2` is
|
| 51 |
-
`T`”.
|
| 52 |
- If `E2` is a (possibly overloaded) member function, function overload
|
| 53 |
-
resolution
|
| 54 |
-
refers
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
of
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
*ref-qualifier*ₒₚₜ returning `T`”, then `E1.E2` is a prvalue. The
|
| 63 |
-
expression designates a non-static member function. The expression
|
| 64 |
-
can be used only as the left-hand operand of a member function
|
| 65 |
-
call ([[class.mfct]]). \[*Note 3*: Any redundant set of parentheses
|
| 66 |
-
surrounding the expression is ignored (
|
| 67 |
-
[[expr.prim]]). — *end note*] The type of `E1.E2` is “function of
|
| 68 |
-
parameter-type-list *cv* returning `T`”.
|
| 69 |
- If `E2` is a nested type, the expression `E1.E2` is ill-formed.
|
| 70 |
- If `E2` is a member enumerator and the type of `E2` is `T`, the
|
| 71 |
expression `E1.E2` is a prvalue. The type of `E1.E2` is `T`.
|
| 72 |
|
| 73 |
If `E2` is a non-static data member or a non-static member function, the
|
| 74 |
program is ill-formed if the class of which `E2` is directly a member is
|
| 75 |
-
an ambiguous base
|
| 76 |
-
[[class.access.base]]
|
| 77 |
|
| 78 |
-
[*Note
|
| 79 |
ambiguous base of the class type of the object expression; see
|
| 80 |
[[class.access.base]]. — *end note*]
|
| 81 |
|
|
|
|
| 1 |
+
#### Class member access <a id="expr.ref">[[expr.ref]]</a>
|
| 2 |
|
| 3 |
A postfix expression followed by a dot `.` or an arrow `->`, optionally
|
| 4 |
+
followed by the keyword `template` [[temp.names]], and then followed by
|
| 5 |
+
an *id-expression*, is a postfix expression. The postfix expression
|
| 6 |
+
before the dot or arrow is evaluated;[^12] the result of that
|
| 7 |
+
evaluation, together with the *id-expression*, determines the result of
|
| 8 |
+
the entire postfix expression.
|
| 9 |
+
|
| 10 |
+
For the first option (dot) the first expression shall be a glvalue. For
|
| 11 |
+
the second option (arrow) the first expression shall be a prvalue having
|
| 12 |
+
pointer type. The expression `E1->E2` is converted to the equivalent
|
| 13 |
+
form `(*(E1)).E2`; the remainder of [[expr.ref]] will address only the
|
| 14 |
+
first option (dot).[^13]
|
| 15 |
+
|
| 16 |
+
Abbreviating *postfix-expression*`.`*id-expression* as `E1.E2`, `E1` is
|
| 17 |
+
called the *object expression*. If the object expression is of scalar
|
| 18 |
+
type, `E2` shall name the pseudo-destructor of that same type (ignoring
|
| 19 |
+
cv-qualifications) and `E1.E2` is an lvalue of type “function of ()
|
| 20 |
+
returning `void`”.
|
| 21 |
+
|
| 22 |
+
[*Note 1*: This value can only be used for a notional function call
|
| 23 |
+
[[expr.prim.id.dtor]]. — *end note*]
|
| 24 |
+
|
| 25 |
+
Otherwise, the object expression shall be of class type. The class type
|
| 26 |
+
shall be complete unless the class member access appears in the
|
| 27 |
+
definition of that class.
|
| 28 |
+
|
| 29 |
+
[*Note 2*: If the class is incomplete, lookup in the complete class
|
| 30 |
+
type is required to refer to the same declaration
|
| 31 |
+
[[basic.scope.class]]. — *end note*]
|
| 32 |
+
|
| 33 |
+
The *id-expression* shall name a member of the class or of one of its
|
| 34 |
+
base classes.
|
| 35 |
+
|
| 36 |
+
[*Note 3*: Because the name of a class is inserted in its class scope
|
| 37 |
+
[[class]], the name of a class is also considered a nested member of
|
| 38 |
+
that class. — *end note*]
|
| 39 |
+
|
| 40 |
+
[*Note 4*: [[basic.lookup.classref]] describes how names are looked up
|
| 41 |
after the `.` and `->` operators. — *end note*]
|
| 42 |
|
| 43 |
+
If `E2` is a bit-field, `E1.E2` is a bit-field. The type and value
|
| 44 |
+
category of `E1.E2` are determined as follows. In the remainder of
|
| 45 |
+
[[expr.ref]], *cq* represents either `const` or the absence of `const`
|
| 46 |
+
and *vq* represents either `volatile` or the absence of `volatile`. *cv*
|
| 47 |
+
represents an arbitrary set of cv-qualifiers, as defined in
|
| 48 |
+
[[basic.type.qualifier]].
|
|
|
|
| 49 |
|
| 50 |
If `E2` is declared to have type “reference to `T`”, then `E1.E2` is an
|
| 51 |
lvalue; the type of `E1.E2` is `T`. Otherwise, one of the following
|
| 52 |
rules applies.
|
| 53 |
|
| 54 |
- If `E2` is a static data member and the type of `E2` is `T`, then
|
| 55 |
`E1.E2` is an lvalue; the expression designates the named member of
|
| 56 |
the class. The type of `E1.E2` is `T`.
|
| 57 |
- If `E2` is a non-static data member and the type of `E1` is “*cq1 vq1*
|
| 58 |
`X`”, and the type of `E2` is “*cq2 vq2* `T`”, the expression
|
| 59 |
+
designates the corresponding member subobject of the object designated
|
| 60 |
+
by the first expression. If `E1` is an lvalue, then `E1.E2` is an
|
| 61 |
+
lvalue; otherwise `E1.E2` is an xvalue. Let the notation *vq12* stand
|
| 62 |
+
for the “union” of *vq1* and *vq2*; that is, if *vq1* or *vq2* is
|
| 63 |
+
`volatile`, then *vq12* is `volatile`. Similarly, let the notation
|
| 64 |
+
*cq12* stand for the “union” of *cq1* and *cq2*; that is, if *cq1* or
|
| 65 |
+
*cq2* is `const`, then *cq12* is `const`. If `E2` is declared to be a
|
| 66 |
+
`mutable` member, then the type of `E1.E2` is “*vq12* `T`”. If `E2` is
|
| 67 |
+
not declared to be a `mutable` member, then the type of `E1.E2` is
|
| 68 |
+
“*cq12* *vq12* `T`”.
|
| 69 |
- If `E2` is a (possibly overloaded) member function, function overload
|
| 70 |
+
resolution [[over.match]] is used to select the function to which `E2`
|
| 71 |
+
refers. The type of `E1.E2` is the type of `E2` and `E1.E2` refers to
|
| 72 |
+
the function referred to by `E2`.
|
| 73 |
+
- If `E2` refers to a static member function, `E1.E2` is an lvalue.
|
| 74 |
+
- Otherwise (when `E2` refers to a non-static member function),
|
| 75 |
+
`E1.E2` is a prvalue. The expression can be used only as the
|
| 76 |
+
left-hand operand of a member function call [[class.mfct]].
|
| 77 |
+
\[*Note 5*: Any redundant set of parentheses surrounding the
|
| 78 |
+
expression is ignored [[expr.prim.paren]]. — *end note*]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
- If `E2` is a nested type, the expression `E1.E2` is ill-formed.
|
| 80 |
- If `E2` is a member enumerator and the type of `E2` is `T`, the
|
| 81 |
expression `E1.E2` is a prvalue. The type of `E1.E2` is `T`.
|
| 82 |
|
| 83 |
If `E2` is a non-static data member or a non-static member function, the
|
| 84 |
program is ill-formed if the class of which `E2` is directly a member is
|
| 85 |
+
an ambiguous base [[class.member.lookup]] of the naming class
|
| 86 |
+
[[class.access.base]] of `E2`.
|
| 87 |
|
| 88 |
+
[*Note 6*: The program is also ill-formed if the naming class is an
|
| 89 |
ambiguous base of the class type of the object expression; see
|
| 90 |
[[class.access.base]]. — *end note*]
|
| 91 |
|