From Jason Turner

[expr.prim.this]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmph3sm1qb3/{from.md → to.md} +21 -14
tmp/tmph3sm1qb3/{from.md → to.md} RENAMED
@@ -1,24 +1,31 @@
1
  ### This <a id="expr.prim.this">[[expr.prim.this]]</a>
2
 
3
- The keyword `this` names a pointer to the object for which a non-static
4
- member function [[class.this]] is invoked or a non-static data member’s
5
- initializer [[class.mem]] is evaluated.
 
 
 
 
 
 
6
 
7
  If a declaration declares a member function or member function template
8
  of a class `X`, the expression `this` is a prvalue of type “pointer to
9
- *cv-qualifier-seq* `X`” between the optional *cv-qualifier-seq* and the
10
- end of the *function-definition*, *member-declarator*, or *declarator*.
11
- It shall not appear before the optional *cv-qualifier-seq* and it shall
12
- not appear within the declaration of a static member function (although
13
- its type and value category are defined within a static member function
14
- as they are within a non-static member function).
 
15
 
16
- [*Note 1*: This is because declaration matching does not occur until
17
  the complete declarator is known. — *end note*]
18
 
19
- [*Note 2*:
20
 
21
  In a *trailing-return-type*, the class being defined is not required to
22
  be complete for purposes of class member access [[expr.ref]]. Class
23
  members declared later are not visible.
24
 
@@ -37,21 +44,21 @@ template auto A::f(int t) -> decltype(t + g());
37
 
38
  — *end note*]
39
 
40
  Otherwise, if a *member-declarator* declares a non-static data member
41
  [[class.mem]] of a class `X`, the expression `this` is a prvalue of type
42
- “pointer to `X`” within the optional default member initializer
43
- [[class.mem]]. It shall not appear elsewhere in the *member-declarator*.
44
 
45
  The expression `this` shall not appear in any other context.
46
 
47
  [*Example 2*:
48
 
49
  ``` cpp
50
  class Outer {
51
  int a[sizeof(*this)]; // error: not inside a member function
52
- unsigned int sz = sizeof(*this); // OK: in default member initializer
53
 
54
  void f() {
55
  int b[sizeof(*this)]; // OK
56
 
57
  struct Inner {
 
1
  ### This <a id="expr.prim.this">[[expr.prim.this]]</a>
2
 
3
+ The keyword `this` names a pointer to the object for which an implicit
4
+ object member function [[class.mfct.non.static]] is invoked or a
5
+ non-static data member’s initializer [[class.mem]] is evaluated.
6
+
7
+ The *current class* at a program point is the class associated with the
8
+ innermost class scope containing that point.
9
+
10
+ [*Note 1*: A *lambda-expression* does not introduce a class
11
+ scope. — *end note*]
12
 
13
  If a declaration declares a member function or member function template
14
  of a class `X`, the expression `this` is a prvalue of type “pointer to
15
+ *cv-qualifier-seq* `X`” wherever `X` is the current class between the
16
+ optional *cv-qualifier-seq* and the end of the *function-definition*,
17
+ *member-declarator*, or *declarator*. It shall not appear within the
18
+ declaration of either a static member function or an explicit object
19
+ member function of the current class (although its type and value
20
+ category are defined within such member functions as they are within an
21
+ implicit object member function).
22
 
23
+ [*Note 2*: This is because declaration matching does not occur until
24
  the complete declarator is known. — *end note*]
25
 
26
+ [*Note 3*:
27
 
28
  In a *trailing-return-type*, the class being defined is not required to
29
  be complete for purposes of class member access [[expr.ref]]. Class
30
  members declared later are not visible.
31
 
 
44
 
45
  — *end note*]
46
 
47
  Otherwise, if a *member-declarator* declares a non-static data member
48
  [[class.mem]] of a class `X`, the expression `this` is a prvalue of type
49
+ “pointer to `X`” wherever `X` is the current class within the optional
50
+ default member initializer [[class.mem]].
51
 
52
  The expression `this` shall not appear in any other context.
53
 
54
  [*Example 2*:
55
 
56
  ``` cpp
57
  class Outer {
58
  int a[sizeof(*this)]; // error: not inside a member function
59
+ unsigned int sz = sizeof(*this); // OK, in default member initializer
60
 
61
  void f() {
62
  int b[sizeof(*this)]; // OK
63
 
64
  struct Inner {