From Jason Turner

[expr.prim.id]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp1h0t02wr/{from.md → to.md} +127 -0
tmp/tmp1h0t02wr/{from.md → to.md} RENAMED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Names <a id="expr.prim.id">[[expr.prim.id]]</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
+ An *id-expression* that denotes a non-static data member or non-static
15
+ member function of a class can only be used:
16
+
17
+ - as part of a class member access ([[expr.ref]]) in which the object
18
+ expression refers to the member’s class[^4] or a class derived from
19
+ that class, or
20
+ - to form a pointer to member ([[expr.unary.op]]), or
21
+ - if that *id-expression* denotes a non-static data member and it
22
+ appears in an unevaluated operand.
23
+ \[*Example 1*:
24
+ ``` cpp
25
+ struct S {
26
+ int m;
27
+ };
28
+ int i = sizeof(S::m); // OK
29
+ int j = sizeof(S::m + 42); // OK
30
+ ```
31
+
32
+ — *end example*]
33
+
34
+ #### Unqualified names <a id="expr.prim.id.unqual">[[expr.prim.id.unqual]]</a>
35
+
36
+ ``` bnf
37
+ unqualified-id:
38
+ identifier
39
+ operator-function-id
40
+ conversion-function-id
41
+ literal-operator-id
42
+ '~' class-name
43
+ '~' decltype-specifier
44
+ template-id
45
+ ```
46
+
47
+ An *identifier* is an *id-expression* provided it has been suitably
48
+ declared (Clause  [[dcl.dcl]]).
49
+
50
+ [*Note 1*: For *operator-function-id*s, see  [[over.oper]]; for
51
+ *conversion-function-id*s, see  [[class.conv.fct]]; for
52
+ *literal-operator-id*s, see  [[over.literal]]; for *template-id*s, see 
53
+ [[temp.names]]. A *class-name* or *decltype-specifier* prefixed by `~`
54
+ denotes a destructor; see  [[class.dtor]]. Within the definition of a
55
+ non-static member function, an *identifier* that names a non-static
56
+ member is transformed to a class member access expression (
57
+ [[class.mfct.non-static]]). — *end note*]
58
+
59
+ The type of the expression is the type of the *identifier*. The result
60
+ is the entity denoted by the identifier. The expression is an lvalue if
61
+ the entity is a function, variable, or data member and a prvalue
62
+ otherwise; it is a bit-field if the identifier designates a bit-field (
63
+ [[dcl.struct.bind]]).
64
+
65
+ #### Qualified names <a id="expr.prim.id.qual">[[expr.prim.id.qual]]</a>
66
+
67
+ ``` bnf
68
+ qualified-id:
69
+ nested-name-specifier 'template'ₒₚₜ unqualified-id
70
+ ```
71
+
72
+ ``` bnf
73
+ nested-name-specifier:
74
+ '::'
75
+ type-name '::'
76
+ namespace-name '::'
77
+ decltype-specifier '::'
78
+ nested-name-specifier identifier '::'
79
+ nested-name-specifier 'template'ₒₚₜ simple-template-id '::'
80
+ ```
81
+
82
+ The type denoted by a *decltype-specifier* in a *nested-name-specifier*
83
+ shall be a class or enumeration type.
84
+
85
+ A *nested-name-specifier* that denotes a class, optionally followed by
86
+ the keyword `template` ([[temp.names]]), and then followed by the name
87
+ of a member of either that class ([[class.mem]]) or one of its base
88
+ classes (Clause  [[class.derived]]), is a *qualified-id*; 
89
+ [[class.qual]] describes name lookup for class members that appear in
90
+ *qualified-id*s. The result is the member. The type of the result is the
91
+ type of the member. The result is an lvalue if the member is a static
92
+ member function or a data member and a prvalue otherwise.
93
+
94
+ [*Note 1*: A class member can be referred to using a *qualified-id* at
95
+ any point in its potential scope (
96
+ [[basic.scope.class]]). — *end note*]
97
+
98
+ Where *class-name* `::~` *class-name* is used, the two *class-name*s
99
+ shall refer to the same class; this notation names the destructor (
100
+ [[class.dtor]]). The form `~` *decltype-specifier* also denotes the
101
+ destructor, but it shall not be used as the *unqualified-id* in a
102
+ *qualified-id*.
103
+
104
+ [*Note 2*: A *typedef-name* that names a class is a *class-name* (
105
+ [[class.name]]). — *end note*]
106
+
107
+ The *nested-name-specifier* `::` names the global namespace. A
108
+ *nested-name-specifier* that names a namespace ([[basic.namespace]]),
109
+ optionally followed by the keyword `template` ([[temp.names]]), and
110
+ then followed by the name of a member of that namespace (or the name of
111
+ a member of a namespace made visible by a *using-directive*), is a
112
+ *qualified-id*;  [[namespace.qual]] describes name lookup for namespace
113
+ members that appear in *qualified-id*s. The result is the member. The
114
+ type of the result is the type of the member. The result is an lvalue if
115
+ the member is a function or a variable and a prvalue otherwise.
116
+
117
+ A *nested-name-specifier* that denotes an enumeration ([[dcl.enum]]),
118
+ followed by the name of an enumerator of that enumeration, is a
119
+ *qualified-id* that refers to the enumerator. The result is the
120
+ enumerator. The type of the result is the type of the enumeration. The
121
+ result is a prvalue.
122
+
123
+ In a *qualified-id*, if the *unqualified-id* is a
124
+ *conversion-function-id*, its *conversion-type-id* shall denote the same
125
+ type in both the context in which the entire *qualified-id* occurs and
126
+ in the context of the class denoted by the *nested-name-specifier*.
127
+