From Jason Turner

[expr.prim.id.general]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpergjx29e/{from.md → to.md} +79 -0
tmp/tmpergjx29e/{from.md → to.md} RENAMED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### General <a id="expr.prim.id.general">[[expr.prim.id.general]]</a>
2
+
3
+ ``` bnf
4
+ id-expression:
5
+ unqualified-id
6
+ qualified-id
7
+ ```
8
+
9
+ An *id-expression* is a restricted form of a *primary-expression*.
10
+
11
+ [*Note 1*: An *id-expression* can appear after `.` and `->` operators
12
+ [[expr.ref]]. — *end note*]
13
+
14
+ If an *id-expression* E denotes a member M of an anonymous union
15
+ [[class.union.anon]] U:
16
+
17
+ - If U is a non-static data member, E refers to M as a member of the
18
+ lookup context of the terminal name of E (after any transformation to
19
+ a class member access expression [[class.mfct.non.static]]).
20
+ \[*Example 1*: `o.x` is interpreted as `o.u.x`, where u names the
21
+ anonymous union member. — *end example*]
22
+ - Otherwise, E is interpreted as a class member access [[expr.ref]] that
23
+ designates the member subobject M of the anonymous union variable for
24
+ U. \[*Note 2*: Under this interpretation, E no longer denotes a
25
+ non-static data member. — *end note*] \[*Example 2*: `N::x` is
26
+ interpreted as `N::u.x`, where u names the anonymous union
27
+ variable. — *end example*]
28
+
29
+ An *id-expression* that denotes a non-static data member or implicit
30
+ object member function of a class can only be used:
31
+
32
+ - as part of a class member access [[expr.ref]] in which the object
33
+ expression refers to the member’s class[^10] or a class derived from
34
+ that class, or
35
+ - to form a pointer to member [[expr.unary.op]], or
36
+ - if that *id-expression* denotes a non-static data member and it
37
+ appears in an unevaluated operand.
38
+ \[*Example 3*:
39
+ ``` cpp
40
+ struct S {
41
+ int m;
42
+ };
43
+ int i = sizeof(S::m); // OK
44
+ int j = sizeof(S::m + 42); // OK
45
+ ```
46
+
47
+ — *end example*]
48
+
49
+ For an *id-expression* that denotes an overload set, overload resolution
50
+ is performed to select a unique function [[over.match]], [[over.over]].
51
+
52
+ [*Note 3*:
53
+
54
+ A program cannot refer to a function with a trailing *requires-clause*
55
+ whose *constraint-expression* is not satisfied, because such functions
56
+ are never selected by overload resolution.
57
+
58
+ [*Example 4*:
59
+
60
+ ``` cpp
61
+ template<typename T> struct A {
62
+ static void f(int) requires false;
63
+ };
64
+
65
+ void g() {
66
+ A<int>::f(0); // error: cannot call f
67
+ void (*p1)(int) = A<int>::f; // error: cannot take the address of f
68
+ decltype(A<int>::f)* p2 = nullptr; // error: the type decltype(A<int>::f) is invalid
69
+ }
70
+ ```
71
+
72
+ In each case, the constraints of `f` are not satisfied. In the
73
+ declaration of `p2`, those constraints are required to be satisfied even
74
+ though `f` is an unevaluated operand [[term.unevaluated.operand]].
75
+
76
+ — *end example*]
77
+
78
+ — *end note*]
79
+