diff --git a/source/basic.tex b/source/basic.tex index c4540cb050..c56f626ef1 100644 --- a/source/basic.tex +++ b/source/basic.tex @@ -3609,7 +3609,7 @@ the backing array of an initializer list\iref{dcl.init.ref}, or \item the object introduced by a call to \tcode{std::meta::reflect_constant_array} - or \tcode{std::meta::\brk{}reflect_con\-stant_string}\iref{meta.reflection.array}, or + or \tcode{std::meta::reflect_constant_string}\iref{meta.define.static}, or \item a subobject thereof. \end{itemize} diff --git a/source/meta.tex b/source/meta.tex index 474ef233ca..a9a0aa706f 100644 --- a/source/meta.tex +++ b/source/meta.tex @@ -2916,7 +2916,13 @@ consteval bool is_string_literal(const char16_t* p); consteval bool is_string_literal(const char32_t* p); - // \ref{meta.define.static}, promoting to static storage strings + // \ref{meta.define.static}, promoting to static storage + namespace meta { + template + consteval info reflect_constant_string(R&& r); + template + consteval info reflect_constant_array(R&& r); + } template consteval const ranges::range_value_t* define_static_string(R&& r); template @@ -3101,13 +3107,6 @@ template consteval info reflect_function(T& fn); - // \ref{meta.reflection.array}, promoting to static storage arrays - template - consteval info reflect_constant_string(R&& r); - - template - consteval info reflect_constant_array(R&& r); - // \ref{meta.reflection.define.aggregate}, class definition generation struct data_member_options; consteval info data_member_spec(info type, data_member_options options); @@ -3370,11 +3369,103 @@ \end{itemize} \end{itemdescr} -\rSec2[meta.define.static]{Promoting to static storage strings} +\rSec2[meta.define.static]{Promoting to static storage} \pnum The functions in this subclause promote compile-time storage into static storage. +\indexlibraryglobal{reflect_constant_string}% +\begin{itemdecl} +template + consteval info reflect_constant_string(R&& r); +\end{itemdecl} + +\begin{itemdescr} +\pnum +Let \tcode{CharT} be \tcode{ranges::range_value_t}. + +\pnum +\mandates +\tcode{CharT} is one of +\tcode{char}, +\tcode{wchar_t}, +\tcode{char8_t}, +\tcode{char16_t}, +\tcode{char32_t}. + +\pnum +Let $V$ be the pack of values of type \tcode{CharT} +whose elements are the corresponding elements of \tcode{r}, +except that if \tcode{r} refers to a string literal object, +then $V$ does not include the trailing null terminator of \tcode{r}. + +\pnum +Let $P$ be the template parameter object\iref{temp.param} +of type \tcode{const CharT[sizeof...(V) + 1]} +initialized with \tcode{\{$V$..., CharT()\}}. + +\pnum +\returns +\tcode{\reflexpr{$P$}}. + +\pnum +\begin{note} +$P$ is a potentially non-unique object\iref{intro.object}. +\end{note} +\end{itemdescr} + +\indexlibraryglobal{reflect_constant_array}% +\begin{itemdecl} +template + consteval info reflect_constant_array(R&& r); +\end{itemdecl} + +\begin{itemdescr} +\pnum +Let \tcode{T} be \tcode{ranges::range_value_t}. + +\pnum +\mandates +\tcode{T} is a structural type\iref{temp.param}, +\tcode{is_constructible_v>} is \tcode{true}, and +\tcode{is_copy_constructible_v} is \tcode{true}. + +\pnum +Let $V$ be the pack of values of type \tcode{info} +of the same size as \tcode{r}, +where the $i^\text{th}$ element is \tcode{reflect_constant($\tcode{e}_i$)}, +where $\tcode{e}_i$ is the $i^\text{th}$ element of \tcode{r}. + +\pnum +Let $P$ be +\begin{itemize} +\item + If \tcode{sizeof...($V$) > 0} is \tcode{true}, + then the template parameter object\iref{temp.param} + of type \tcode{const T[\brk{}sizeof...(\brk{}$V$)]} + initialized with \tcode{\{[:$V$:]...\}}. +\item + Otherwise, the template parameter object + of type \tcode{array} + initialized with \tcode{\{\}}. +\end{itemize} + +\pnum +\returns +\tcode{\reflexpr{$P$}}. + +\pnum +\throws +\tcode{meta::exception} unless +\tcode{reflect_constant(e)} is a constant subexpression +for every element \tcode{e} of \tcode{r}. + +\pnum +\begin{note} +$P$ is a potentially non-unique object\iref{intro.object}. +\end{note} +\end{itemdescr} + \indexlibraryglobal{define_static_string}% \begin{itemdecl} template @@ -6202,103 +6293,6 @@ for a constant template parameter of type \tcode{T\&}\iref{temp.arg.nontype}. \end{itemdescr} -\rSec2[meta.reflection.array]{Promoting to static storage arrays} - -\pnum -The functions in this subclause promote compile-time storage into static storage. - -\indexlibraryglobal{reflect_constant_string}% -\begin{itemdecl} -template - consteval info reflect_constant_string(R&& r); -\end{itemdecl} - -\begin{itemdescr} -\pnum -Let \tcode{CharT} be \tcode{ranges::range_value_t}. - -\pnum -\mandates -\tcode{CharT} is one of -\tcode{char}, -\tcode{wchar_t}, -\tcode{char8_t}, -\tcode{char16_t}, -\tcode{char32_t}. - -\pnum -Let $V$ be the pack of values of type \tcode{CharT} -whose elements are the corresponding elements of \tcode{r}, -except that if \tcode{r} refers to a string literal object, -then $V$ does not include the trailing null terminator of \tcode{r}. - -\pnum -Let $P$ be the template parameter object\iref{temp.param} -of type \tcode{const CharT[sizeof...(V) + 1]} -initialized with \tcode{\{$V$..., CharT()\}}. - -\pnum -\returns -\tcode{\reflexpr{$P$}}. - -\pnum -\begin{note} -$P$ is a potentially non-unique object\iref{intro.object}. -\end{note} -\end{itemdescr} - -\indexlibraryglobal{reflect_constant_array}% -\begin{itemdecl} -template - consteval info reflect_constant_array(R&& r); -\end{itemdecl} - -\begin{itemdescr} -\pnum -Let \tcode{T} be \tcode{ranges::range_value_t}. - -\pnum -\mandates -\tcode{T} is a structural type\iref{temp.param}, -\tcode{is_constructible_v>} is \tcode{true}, and -\tcode{is_copy_constructible_v} is \tcode{true}. - -\pnum -Let $V$ be the pack of values of type \tcode{info} -of the same size as \tcode{r}, -where the $i^\text{th}$ element is \tcode{reflect_constant($\tcode{e}_i$)}, -where $\tcode{e}_i$ is the $i^\text{th}$ element of \tcode{r}. - -\pnum -Let $P$ be -\begin{itemize} -\item - If \tcode{sizeof...($V$) > 0} is \tcode{true}, - then the template parameter object\iref{temp.param} - of type \tcode{const T[\brk{}sizeof...(\brk{}$V$)]} - initialized with \tcode{\{[:$V$:]...\}}. -\item - Otherwise, the template parameter object - of type \tcode{array} - initialized with \tcode{\{\}}. -\end{itemize} - -\pnum -\returns -\tcode{\reflexpr{$P$}}. - -\pnum -\throws -\tcode{meta::exception} unless -\tcode{reflect_constant(e)} is a constant subexpression -for every element \tcode{e} of \tcode{r}. - -\pnum -\begin{note} -$P$ is a potentially non-unique object\iref{intro.object}. -\end{note} -\end{itemdescr} - \rSec2[meta.reflection.define.aggregate]{Reflection class definition generation} \indexlibraryglobal{data_member_options}%