From Jason Turner

[meta.reflection.member.queries]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmps2skst7x/{from.md → to.md} +168 -0
tmp/tmps2skst7x/{from.md → to.md} RENAMED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Reflection member queries <a id="meta.reflection.member.queries">[[meta.reflection.member.queries]]</a>
2
+
3
+ ``` cpp
4
+ consteval vector<info> members_of(info r, access_context ctx);
5
+ ```
6
+
7
+ A declaration D *members-of-precedes* a point P if D precedes either P
8
+ or the point immediately following the *class-specifier* of the
9
+ outermost class for which P is in a complete-class context.
10
+
11
+ A declaration D of a member M of a class or namespace Q is
12
+ *Q-members-of-eligible* if
13
+
14
+ - the host scope of D[[basic.scope.scope]] is the class scope or
15
+ namespace scope associated with Q,
16
+ - D is not a friend declaration,
17
+ - M is not a closure type [[expr.prim.lambda.closure]],
18
+ - M is not a specialization of a template [[temp.pre]],
19
+ - if Q is a class that is not a closure type, then M is a direct member
20
+ of Q[[class.mem.general]] that is not a variant member of a nested
21
+ anonymous union of Q[[class.union.anon]], and
22
+ - if Q is a closure type, then M is a function call operator or function
23
+ call operator template.
24
+
25
+ It is *implementation-defined* whether declarations of other members of
26
+ a closure type Q are Q-members-of-eligible.
27
+
28
+ A member M of a class or namespace Q is *Q-members-of-representable*
29
+ from a point P if a Q-members-of-eligible declaration of M
30
+ members-of-precedes P, and M is
31
+
32
+ - a class or enumeration type,
33
+ - a type alias,
34
+ - a class template, function template, variable template, alias
35
+ template, or concept,
36
+ - a variable or reference V for which the type of V does not contain an
37
+ undeduced placeholder type,
38
+ - a function F for which
39
+ - the type of F does not contain an undeduced placeholder type,
40
+ - the constraints (if any) of F are satisfied, and
41
+ - if F is a prospective destructor, F is the selected
42
+ destructor [[class.dtor]],
43
+ - a non-static data member,
44
+ - a namespace, or
45
+ - a namespace alias.
46
+
47
+ [*Note 1*: Examples of direct members that are not
48
+ Q-members-of-representable for any entity Q include: unscoped
49
+ enumerators [[enum]], partial specializations of
50
+ templates [[temp.spec.partial]], and closure
51
+ types [[expr.prim.lambda.closure]]. — *end note*]
52
+
53
+ *Returns:* A `vector` containing reflections of all members M of the
54
+ entity Q represented by `dealias(r)` for which
55
+
56
+ - M is Q-members-of-representable from some point in the evaluation
57
+ context and
58
+ - `is_accessible(``, ctx)` is `true`.
59
+
60
+ If `dealias(r)` represents a class C, then the `vector` also contains
61
+ reflections representing all unnamed bit-fields B whose declarations
62
+ inhabit the class scope corresponding to C for which
63
+ `is_accessible(``, ctx)` is `true`. Reflections of class members and
64
+ unnamed bit-fields that are declared appear in the order in which they
65
+ are declared.
66
+
67
+ [*Note 2*: Base classes are not members. Implicitly-declared special
68
+ members appear after any user-declared
69
+ members [[special]]. — *end note*]
70
+
71
+ *Throws:* `meta::exception` unless `dealias(r)` is a reflection
72
+ representing either a class type that is complete from some point in the
73
+ evaluation context or a namespace.
74
+
75
+ [*Example 1*:
76
+
77
+ ``` cpp
78
+ // TU1
79
+ export module M;
80
+ namespace NS {
81
+ export int m;
82
+ static int l;
83
+ }
84
+ static_assert(members_of(^^NS, access_context::current()).size() == 2);
85
+
86
+ // TU2
87
+ import M;
88
+
89
+ static_assert( // NS::l does not precede
90
+ members_of(^^NS, access_context::current()).size() == 1); // the constant-expression [basic.lookup]
91
+
92
+ class B {};
93
+
94
+ struct S : B {
95
+ private:
96
+ class I;
97
+ public:
98
+ int m;
99
+ };
100
+
101
+ static_assert( // 6 special members,
102
+ members_of(^^S, access_context::current()).size() == 7); // 1 public member,
103
+ // does not include base
104
+
105
+ static_assert( // all of the above,
106
+ members_of(^^S, access_context::unchecked()).size() == 8); // as well as a reflection
107
+ // representing S::I
108
+ ```
109
+
110
+ — *end example*]
111
+
112
+ ``` cpp
113
+ consteval vector<info> bases_of(info type, access_context ctx);
114
+ ```
115
+
116
+ *Returns:* Let C be the class represented by `dealias(type)`. A `vector`
117
+ containing the reflections of all the direct base class relationships B,
118
+ if any, of C such that `is_accessible(``, ctx)` is `true`. The direct
119
+ base class relationships appear in the order in which the corresponding
120
+ base classes appear in the *base-specifier-list* of C.
121
+
122
+ *Throws:* `meta::exception` unless `dealias(type)` represents a class
123
+ type that is complete from some point in the evaluation context.
124
+
125
+ ``` cpp
126
+ consteval vector<info> static_data_members_of(info type, access_context ctx);
127
+ ```
128
+
129
+ *Returns:* A `vector` containing each element `e` of
130
+ `members_of(type, ctx)` such that `is_variable(e)` is `true`, preserving
131
+ their order.
132
+
133
+ *Throws:* `meta::exception` unless `dealias(type)` represents a class
134
+ type that is complete from some point in the evaluation context.
135
+
136
+ ``` cpp
137
+ consteval vector<info> nonstatic_data_members_of(info type, access_context ctx);
138
+ ```
139
+
140
+ *Returns:* A `vector` containing each element `e` of
141
+ `members_of(type, ctx)` such that `is_nonstatic_data_member(e)` is
142
+ `true`, preserving their order.
143
+
144
+ *Throws:* `meta::exception` unless `dealias(type)` represents a class
145
+ type that is complete from some point in the evaluation context.
146
+
147
+ ``` cpp
148
+ consteval vector<info> subobjects_of(info type, access_context ctx);
149
+ ```
150
+
151
+ *Returns:* A `vector` containing each element of `bases_of(type, ctx)`
152
+ followed by each element of `nonstatic_data_members_of(type, ctx)`,
153
+ preserving their order.
154
+
155
+ *Throws:* `meta::exception` unless `dealias(type)` represents a class
156
+ type that is complete from some point in the evaluation context.
157
+
158
+ ``` cpp
159
+ consteval vector<info> enumerators_of(info type_enum);
160
+ ```
161
+
162
+ *Returns:* A `vector` containing the reflections of each enumerator of
163
+ the enumeration represented by `dealias(type_enum)`, in the order in
164
+ which they are declared.
165
+
166
+ *Throws:* `meta::exception` unless `dealias(type_enum)` represents an
167
+ enumeration type, and `is_enumerable_type(type_enum)` is `true`.
168
+