From Jason Turner

[meta.reflection.access.queries]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp9upjlnu5/{from.md → to.md} +113 -0
tmp/tmp9upjlnu5/{from.md → to.md} RENAMED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Member accessibility queries <a id="meta.reflection.access.queries">[[meta.reflection.access.queries]]</a>
2
+
3
+ ``` cpp
4
+ consteval bool is_accessible(info r, access_context ctx);
5
+ ```
6
+
7
+ Let *`PARENT-CLS`*`(r)` be:
8
+
9
+ - If `parent_of(r)` represents a class C, then C.
10
+ - Otherwise, *`PARENT-CLS`*`(parent_of(r))`.
11
+
12
+ Let *`DESIGNATING-CLS`*`(r, ctx)` be:
13
+
14
+ - If `ctx.designating_class()` represents a class C, then C.
15
+ - Otherwise, *`PARENT-CLS`*`(r)`.
16
+
17
+ *Returns:*
18
+
19
+ - If `r` represents an unnamed bit-field F, then
20
+ `is_accessible(``r_H``, ctx)`, where `r_H` represents a hypothetical
21
+ non-static data member of the class represented by *`PARENT-CLS`*`(r)`
22
+ with the same access as F. \[*Note 1*: Unnamed bit-fields are treated
23
+ as class members for the purpose of `is_accessible`. — *end note*]
24
+ - Otherwise, if `r` does not represent a class member or a direct base
25
+ class relationship, then `true`.
26
+ - Otherwise, if `r` represents
27
+ - a class member that is not a (possibly indirect or variant) member
28
+ of *`DESIGNATING-CLS`*`(r, ctx)` or
29
+ - a direct base class relationship such that `parent_of(r)` does not
30
+ represent *`DESIGNATING-CLS`*`(r, ctx)` or a (direct or indirect)
31
+ base class thereof,
32
+
33
+ then `false`.
34
+ - Otherwise, if `ctx.scope()` is the null reflection, then `true`.
35
+ - Otherwise, letting P be a program point whose immediate scope is the
36
+ function parameter scope, class scope, or namespace scope
37
+ corresponding to the function, class, or namespace represented by
38
+ `ctx.scope()`:
39
+ - If `r` represents a direct base class relationship (D, B), then
40
+ `true` if base class B of *`DESIGNATING-CLS`*`(r, ctx)` is
41
+ accessible at P[[class.access.base]]; otherwise `false`.
42
+ - Otherwise, `r` represents a class member M; `true` if M would be
43
+ accessible at P with the designating class [[class.access.base]] as
44
+ *`DESIGNATING-CLS`*`(r, ctx)` if the effect of any
45
+ *using-declaration*s [[namespace.udecl]] were ignored. Otherwise,
46
+ `false`.
47
+
48
+ [*Note 1*: The definitions of when a class member or base class is
49
+ accessible from a point P do not consider whether a declaration of that
50
+ entity is reachable from P. — *end note*]
51
+
52
+ *Throws:* `meta::exception` if
53
+
54
+ - `r` represents a class member for which *`PARENT-CLS`*`(r)` is an
55
+ incomplete class or
56
+ - `r` represents a direct base class relationship (D, B) for which D is
57
+ incomplete.
58
+
59
+ [*Example 1*:
60
+
61
+ ``` cpp
62
+ consteval access_context fn() {
63
+ return access_context::current();
64
+ }
65
+
66
+ class Cls {
67
+ int mem;
68
+ friend consteval access_context fn();
69
+ public:
70
+ static constexpr auto r = ^^mem;
71
+ };
72
+
73
+ static_assert(is_accessible(Cls::r, fn())); // OK
74
+ static_assert(!is_accessible(Cls::r, access_context::current())); // OK
75
+ static_assert(is_accessible(Cls::r, access_context::unchecked())); // OK
76
+ ```
77
+
78
+ — *end example*]
79
+
80
+ ``` cpp
81
+ consteval bool has_inaccessible_nonstatic_data_members(info r, access_context ctx);
82
+ ```
83
+
84
+ *Returns:* `true` if `is_accessible(`R`, ctx)` is `false` for any R in
85
+ `nonstatic_data_members_of(r, access_context::unchecked())`. Otherwise,
86
+ `false`.
87
+
88
+ *Throws:* `meta::exception` unless
89
+
90
+ - `nonstatic_data_members_of(r, access_context::unchecked())` is a
91
+ constant subexpression and
92
+ - `r` does not represent a closure type.
93
+
94
+ ``` cpp
95
+ consteval bool has_inaccessible_bases(info r, access_context ctx);
96
+ ```
97
+
98
+ *Returns:* `true` if `is_accessible(`R`, ctx)` is `false` for any R in
99
+ `bases_of(r, access_context::unchecked())`. Otherwise, `false`.
100
+
101
+ *Throws:* `meta::exception` unless
102
+ `bases_of(r, access_context::unchecked())` is a constant subexpression.
103
+
104
+ ``` cpp
105
+ consteval bool has_inaccessible_subobjects(info r, access_context ctx);
106
+ ```
107
+
108
+ *Effects:* Equivalent to:
109
+
110
+ ``` cpp
111
+ return has_inaccessible_bases(r, ctx) || has_inaccessible_nonstatic_data_members(r, ctx);
112
+ ```
113
+