tmp/tmp4mg7fu6v/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Expression result reflection <a id="meta.reflection.result">[[meta.reflection.result]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
template<class T>
|
| 5 |
+
consteval info reflect_constant(T expr);
|
| 6 |
+
```
|
| 7 |
+
|
| 8 |
+
*Mandates:* `is_copy_constructible_v<T>` is `true` and `T` is a
|
| 9 |
+
cv-unqualified structural type [[temp.param]] that is not a reference
|
| 10 |
+
type.
|
| 11 |
+
|
| 12 |
+
Let V be:
|
| 13 |
+
|
| 14 |
+
- if `T` is a class type, then an object that is
|
| 15 |
+
template-argument-equivalent to the value of `expr`;
|
| 16 |
+
- otherwise, the value of `expr`.
|
| 17 |
+
|
| 18 |
+
Let `TCls` be the invented template:
|
| 19 |
+
|
| 20 |
+
``` cpp
|
| 21 |
+
template<T P> struct TCls;
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
*Returns:* `template_arguments_of(``)[0]`.
|
| 25 |
+
|
| 26 |
+
[*Note 1*: This is a reflection of an object for class types, and a
|
| 27 |
+
reflection of a value otherwise. — *end note*]
|
| 28 |
+
|
| 29 |
+
*Throws:* `meta::exception` unless the *template-id* `TCls<`V`>` would
|
| 30 |
+
be valid.
|
| 31 |
+
|
| 32 |
+
[*Example 1*:
|
| 33 |
+
|
| 34 |
+
``` cpp
|
| 35 |
+
template<auto D>
|
| 36 |
+
struct A { };
|
| 37 |
+
|
| 38 |
+
struct N { int x; };
|
| 39 |
+
struct K { char const* p; };
|
| 40 |
+
|
| 41 |
+
constexpr info r1 = reflect_constant(42);
|
| 42 |
+
static_assert(is_value(r1));
|
| 43 |
+
static_assert(r1 == template_arguments_of(^^A<42>)[0]);
|
| 44 |
+
|
| 45 |
+
constexpr info r2 = reflect_constant(N{42});
|
| 46 |
+
static_assert(is_object(r2));
|
| 47 |
+
static_assert(r2 == template_arguments_of(^^A<N{42}>)[0]);
|
| 48 |
+
|
| 49 |
+
constexpr info r3 = reflect_constant(K{nullptr}); // OK
|
| 50 |
+
constexpr info r4 = reflect_constant(K{"ebab"}); // error: constituent pointer
|
| 51 |
+
// points to string literal
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
— *end example*]
|
| 55 |
+
|
| 56 |
+
``` cpp
|
| 57 |
+
template<class T>
|
| 58 |
+
consteval info reflect_object(T& expr);
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
*Mandates:* `T` is an object type.
|
| 62 |
+
|
| 63 |
+
*Returns:* A reflection of the object designated by `expr`.
|
| 64 |
+
|
| 65 |
+
*Throws:* `meta::exception` unless `expr` is suitable for use as a
|
| 66 |
+
constant template argument for a constant template parameter of type
|
| 67 |
+
`T&` [[temp.arg.nontype]].
|
| 68 |
+
|
| 69 |
+
``` cpp
|
| 70 |
+
template<class T>
|
| 71 |
+
consteval info reflect_function(T& fn);
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
*Mandates:* `T` is a function type.
|
| 75 |
+
|
| 76 |
+
*Returns:* A reflection of the function designated by `fn`.
|
| 77 |
+
|
| 78 |
+
*Throws:* `meta::exception` unless `fn` is suitable for use as a
|
| 79 |
+
constant template argument for a constant template parameter of type
|
| 80 |
+
`T&` [[temp.arg.nontype]].
|
| 81 |
+
|