From Jason Turner

[meta.define.static]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp4y6spm8k/{from.md → to.md} +107 -0
tmp/tmp4y6spm8k/{from.md → to.md} RENAMED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Promoting to static storage <a id="meta.define.static">[[meta.define.static]]</a>
2
+
3
+ The functions in this subclause promote compile-time storage into static
4
+ storage.
5
+
6
+ ``` cpp
7
+ template<ranges::input_range R>
8
+ consteval info reflect_constant_string(R&& r);
9
+ ```
10
+
11
+ Let `CharT` be `ranges::range_value_t<R>`.
12
+
13
+ *Mandates:* `CharT` is one of `char`, `wchar_t`, `char8_t`, `char16_t`,
14
+ `char32_t`.
15
+
16
+ Let V be the pack of values of type `CharT` whose elements are the
17
+ corresponding elements of `r`, except that if `r` refers to a string
18
+ literal object, then V does not include the trailing null terminator of
19
+ `r`.
20
+
21
+ Let P be the template parameter object [[temp.param]] of type
22
+ `const CharT[sizeof...(V) + 1]` initialized with `{`V`..., CharT()}`.
23
+
24
+ *Returns:* .
25
+
26
+ [*Note 1*: P is a potentially non-unique
27
+ object [[intro.object]]. — *end note*]
28
+
29
+ ``` cpp
30
+ template<ranges::input_range R>
31
+ consteval info reflect_constant_array(R&& r);
32
+ ```
33
+
34
+ Let `T` be `ranges::range_value_t<R>`.
35
+
36
+ *Mandates:* `T` is a structural type [[temp.param]],
37
+ `is_constructible_v<T, ranges::range_reference_t<R>>` is `true`, and
38
+ `is_copy_constructible_v<T>` is `true`.
39
+
40
+ Let V be the pack of values of type `info` of the same size as `r`,
41
+ where the iᵗʰ element is `reflect_constant(``eᵢ``)`, where `eᵢ` is the
42
+ iᵗʰ element of `r`.
43
+
44
+ Let P be
45
+
46
+ - If `sizeof...(`V`) > 0` is `true`, then the template parameter
47
+ object [[temp.param]] of type `const T[sizeof...(`V`)]` initialized
48
+ with `{[:`V`:]...}`.
49
+ - Otherwise, the template parameter object of type `const array<T, 0>`
50
+ initialized with `{}`.
51
+
52
+ *Returns:* .
53
+
54
+ *Throws:* `meta::exception` unless `reflect_constant(e)` is a constant
55
+ subexpression for every element `e` of `r`.
56
+
57
+ [*Note 2*: P is a potentially non-unique
58
+ object [[intro.object]]. — *end note*]
59
+
60
+ ``` cpp
61
+ template<ranges::input_range R>
62
+ consteval const ranges::range_value_t<R>* define_static_string(R&& r);
63
+ ```
64
+
65
+ *Effects:* Equivalent to:
66
+
67
+ ``` cpp
68
+ return meta::extract<const ranges::range_value_t<R>*>(meta::reflect_constant_string(r));
69
+ ```
70
+
71
+ ``` cpp
72
+ template<ranges::input_range R>
73
+ consteval span<const ranges::range_value_t<R>> define_static_array(R&& r);
74
+ ```
75
+
76
+ *Effects:* Equivalent to:
77
+
78
+ ``` cpp
79
+ using T = ranges::range_value_t<R>;
80
+ meta::info array = meta::reflect_constant_array(r);
81
+ if (meta::is_array_type(meta::type_of(array))) {
82
+ return span<const T>(meta::extract<const T*>(array), meta::extent(meta::type_of(array)));
83
+ } else {
84
+ return span<const T>();
85
+ }
86
+ ```
87
+
88
+ ``` cpp
89
+ template<class T>
90
+ consteval const remove_cvref_t<T>* define_static_object(T&& t);
91
+ ```
92
+
93
+ *Effects:* Equivalent to:
94
+
95
+ ``` cpp
96
+ using U = remove_cvref_t<T>;
97
+ if constexpr (meta::is_class_type(^^U)) {
98
+ return addressof(meta::extract<const U&>(meta::reflect_constant(std::forward<T>(t))));
99
+ } else {
100
+ return define_static_array(span(addressof(t), 1)).data();
101
+ }
102
+ ```
103
+
104
+ [*Note 3*: For class types, `define_static_object` provides the address
105
+ of the template parameter object [[temp.param]] that is
106
+ template-argument equivalent to `t`. — *end note*]
107
+