tmp/tmp2qt0zxli/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Value extraction <a id="meta.reflection.extract">[[meta.reflection.extract]]</a>
|
| 2 |
+
|
| 3 |
+
The `extract` function template may be used to extract a value out of a
|
| 4 |
+
reflection when its type is known.
|
| 5 |
+
|
| 6 |
+
The following are defined for exposition only to aid in the
|
| 7 |
+
specification of `extract`.
|
| 8 |
+
|
| 9 |
+
``` cpp
|
| 10 |
+
template<class T>
|
| 11 |
+
consteval T extract-ref(info r); // exposition only
|
| 12 |
+
```
|
| 13 |
+
|
| 14 |
+
[*Note 1*: `T` is a reference type. — *end note*]
|
| 15 |
+
|
| 16 |
+
*Returns:* If `r` represents an object O, then a reference to O.
|
| 17 |
+
Otherwise, a reference to the object declared, or referred to, by the
|
| 18 |
+
variable represented by `r`.
|
| 19 |
+
|
| 20 |
+
*Throws:* `meta::exception` unless
|
| 21 |
+
|
| 22 |
+
- `r` represents a variable or object of type `U`,
|
| 23 |
+
- `is_convertible_v<remove_reference_t<U>(*)[], remove_reference_t<T>(*)[]>`
|
| 24 |
+
is `true`, and \[*Note 1*: The intent is to allow only qualification
|
| 25 |
+
conversion from `U` to `T`. — *end note*]
|
| 26 |
+
- If `r` represents a variable, then either that variable is usable in
|
| 27 |
+
constant expressions or its lifetime began within the core constant
|
| 28 |
+
expression currently under evaluation.
|
| 29 |
+
|
| 30 |
+
``` cpp
|
| 31 |
+
template<class T>
|
| 32 |
+
consteval T extract-member-or-function(info r); // exposition only
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
*Returns:*
|
| 36 |
+
|
| 37 |
+
- If `T` is a pointer type, then a pointer value pointing to the
|
| 38 |
+
function represented by `r`.
|
| 39 |
+
- Otherwise, a pointer-to-member value designating the non-static data
|
| 40 |
+
member or function represented by `r`.
|
| 41 |
+
|
| 42 |
+
*Throws:* `meta::exception` unless
|
| 43 |
+
|
| 44 |
+
- `r` represents a non-static data member with type `X`, that is not a
|
| 45 |
+
bit-field, that is a direct member of class `C`, `T` and `X C::*` are
|
| 46 |
+
similar types [[conv.qual]], and `is_convertible_v<X C::*, T>` is
|
| 47 |
+
`true`;
|
| 48 |
+
- `r` represents an implicit object member function with type `F` or
|
| 49 |
+
`F noexcept` that is a direct member of a class `C`, and `T` is
|
| 50 |
+
`F C::*`; or
|
| 51 |
+
- `r` represents a non-member function, static member function, or
|
| 52 |
+
explicit object member function of function type `F` or `F noexcept`,
|
| 53 |
+
and `T` is `F*`.
|
| 54 |
+
|
| 55 |
+
``` cpp
|
| 56 |
+
template<class T>
|
| 57 |
+
consteval T extract-value(info r); // exposition only
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
Let `U` be the type of the value or object that `r` represents.
|
| 61 |
+
|
| 62 |
+
*Returns:* `static_cast<T>([:`R`:])`, where R is a constant expression
|
| 63 |
+
of type `info` such that R` == r` is `true`.
|
| 64 |
+
|
| 65 |
+
*Throws:* `meta::exception` unless
|
| 66 |
+
|
| 67 |
+
- `U` is a pointer type, `T` and `U` are either similar [[conv.qual]] or
|
| 68 |
+
both function pointer types, and `is_convertible_v<U, T>` is `true`,
|
| 69 |
+
- `U` is not a pointer type and the cv-unqualified types of `T` and `U`
|
| 70 |
+
are the same,
|
| 71 |
+
- `U` is an array type, `T` is a pointer type, and the value `r`
|
| 72 |
+
represents is convertible to `T`, or
|
| 73 |
+
- `U` is a closure type, `T` is a function pointer type, and the value
|
| 74 |
+
that `r` represents is convertible to `T`.
|
| 75 |
+
|
| 76 |
+
``` cpp
|
| 77 |
+
template<class T>
|
| 78 |
+
consteval T extract(info r);
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
Let `U` be `remove_cv_t<T>`.
|
| 82 |
+
|
| 83 |
+
*Effects:* Equivalent to:
|
| 84 |
+
|
| 85 |
+
``` cpp
|
| 86 |
+
if constexpr (is_reference_type(^^T)) {
|
| 87 |
+
return extract-ref<T>(r);
|
| 88 |
+
} else if (is_nonstatic_data_member(r) || is_function(r)) {
|
| 89 |
+
return extract-member-or-function<U>(r);
|
| 90 |
+
} else {
|
| 91 |
+
return extract-value<U>(constant_of(r));
|
| 92 |
+
}
|
| 93 |
+
```
|
| 94 |
+
|