Skip to content

Commit 363c3a5

Browse files
jensmaurertkoeppe
authored andcommitted
[meta.reflection.array] Integrate subclause into [meta.define.static]
Fixes NB US 86-157 (C++26 CD). Fixes NB US 119-180 (C++26 CD). Fixes NB US 89-196 (C++26 CD).
1 parent 5d916dc commit 363c3a5

File tree

2 files changed

+101
-107
lines changed

2 files changed

+101
-107
lines changed

source/basic.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3613,7 +3613,7 @@
36133613
the backing array of an initializer list\iref{dcl.init.ref}, or
36143614
\item
36153615
the object introduced by a call to \tcode{std::meta::reflect_constant_array}
3616-
or \tcode{std::meta::\brk{}reflect_con\-stant_string}\iref{meta.reflection.array}, or
3616+
or \tcode{std::meta::reflect_constant_string}\iref{meta.define.static}, or
36173617
\item
36183618
a subobject thereof.
36193619
\end{itemize}

source/meta.tex

Lines changed: 100 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -2920,7 +2920,13 @@
29202920
consteval bool is_string_literal(const char16_t* p);
29212921
consteval bool is_string_literal(const char32_t* p);
29222922

2923-
// \ref{meta.define.static}, promoting to static storage strings
2923+
// \ref{meta.define.static}, promoting to static storage
2924+
namespace meta {
2925+
template<ranges::@\libconcept{input_range}@ R>
2926+
consteval info reflect_constant_string(R&& r);
2927+
template<ranges::@\libconcept{input_range}@ R>
2928+
consteval info reflect_constant_array(R&& r);
2929+
}
29242930
template<ranges::@\libconcept{input_range}@ R>
29252931
consteval const ranges::range_value_t<R>* define_static_string(R&& r);
29262932
template<ranges::@\libconcept{input_range}@ R>
@@ -3109,13 +3115,6 @@
31093115
template<class T>
31103116
consteval info reflect_function(T& fn);
31113117

3112-
// \ref{meta.reflection.array}, promoting to static storage arrays
3113-
template<ranges::@\libconcept{input_range}@ R>
3114-
consteval info reflect_constant_string(R&& r);
3115-
3116-
template<ranges::@\libconcept{input_range}@ R>
3117-
consteval info reflect_constant_array(R&& r);
3118-
31193118
// \ref{meta.reflection.define.aggregate}, class definition generation
31203119
struct data_member_options;
31213120
consteval info data_member_spec(info type, data_member_options options);
@@ -3374,11 +3373,103 @@
33743373
\end{itemize}
33753374
\end{itemdescr}
33763375

3377-
\rSec2[meta.define.static]{Promoting to static storage strings}
3376+
\rSec2[meta.define.static]{Promoting to static storage}
33783377

33793378
\pnum
33803379
The functions in this subclause promote compile-time storage into static storage.
33813380

3381+
\indexlibraryglobal{reflect_constant_string}%
3382+
\begin{itemdecl}
3383+
template<ranges::@\libconcept{input_range}@ R>
3384+
consteval info reflect_constant_string(R&& r);
3385+
\end{itemdecl}
3386+
3387+
\begin{itemdescr}
3388+
\pnum
3389+
Let \tcode{CharT} be \tcode{ranges::range_value_t<R>}.
3390+
3391+
\pnum
3392+
\mandates
3393+
\tcode{CharT} is one of
3394+
\tcode{char},
3395+
\tcode{wchar_t},
3396+
\tcode{char8_t},
3397+
\tcode{char16_t},
3398+
\tcode{char32_t}.
3399+
3400+
\pnum
3401+
Let $V$ be the pack of values of type \tcode{CharT}
3402+
whose elements are the corresponding elements of \tcode{r},
3403+
except that if \tcode{r} refers to a string literal object,
3404+
then $V$ does not include the trailing null terminator of \tcode{r}.
3405+
3406+
\pnum
3407+
Let $P$ be the template parameter object\iref{temp.param}
3408+
of type \tcode{const CharT[sizeof...(V) + 1]}
3409+
initialized with \tcode{\{$V$..., CharT()\}}.
3410+
3411+
\pnum
3412+
\returns
3413+
\tcode{\reflexpr{$P$}}.
3414+
3415+
\pnum
3416+
\begin{note}
3417+
$P$ is a potentially non-unique object\iref{intro.object}.
3418+
\end{note}
3419+
\end{itemdescr}
3420+
3421+
\indexlibraryglobal{reflect_constant_array}%
3422+
\begin{itemdecl}
3423+
template<ranges::@\libconcept{input_range}@ R>
3424+
consteval info reflect_constant_array(R&& r);
3425+
\end{itemdecl}
3426+
3427+
\begin{itemdescr}
3428+
\pnum
3429+
Let \tcode{T} be \tcode{ranges::range_value_t<R>}.
3430+
3431+
\pnum
3432+
\mandates
3433+
\tcode{T} is a structural type\iref{temp.param},
3434+
\tcode{is_constructible_v<T, ranges::range_reference_t<R>>} is \tcode{true}, and
3435+
\tcode{is_copy_constructible_v<T>} is \tcode{true}.
3436+
3437+
\pnum
3438+
Let $V$ be the pack of values of type \tcode{info}
3439+
of the same size as \tcode{r},
3440+
where the $i^\text{th}$ element is \tcode{reflect_constant($\tcode{e}_i$)},
3441+
where $\tcode{e}_i$ is the $i^\text{th}$ element of \tcode{r}.
3442+
3443+
\pnum
3444+
Let $P$ be
3445+
\begin{itemize}
3446+
\item
3447+
If \tcode{sizeof...($V$) > 0} is \tcode{true},
3448+
then the template parameter object\iref{temp.param}
3449+
of type \tcode{const T[\brk{}sizeof...(\brk{}$V$)]}
3450+
initialized with \tcode{\{[:$V$:]...\}}.
3451+
\item
3452+
Otherwise, the template parameter object
3453+
of type \tcode{const array<T, 0>}
3454+
initialized with \tcode{\{\}}.
3455+
\end{itemize}
3456+
3457+
\pnum
3458+
\returns
3459+
\tcode{\reflexpr{$P$}}.
3460+
3461+
\pnum
3462+
\throws
3463+
\tcode{meta::exception} unless
3464+
\tcode{reflect_constant(e)} is a constant subexpression
3465+
for every element \tcode{e} of \tcode{r}.
3466+
3467+
\pnum
3468+
\begin{note}
3469+
$P$ is a potentially non-unique object\iref{intro.object}.
3470+
\end{note}
3471+
\end{itemdescr}
3472+
33823473
\indexlibraryglobal{define_static_string}%
33833474
\begin{itemdecl}
33843475
template<ranges::@\libconcept{input_range}@ R>
@@ -6319,103 +6410,6 @@
63196410
for a constant template parameter of type \tcode{T\&}\iref{temp.arg.nontype}.
63206411
\end{itemdescr}
63216412

6322-
\rSec2[meta.reflection.array]{Promoting to static storage arrays}
6323-
6324-
\pnum
6325-
The functions in this subclause promote compile-time storage into static storage.
6326-
6327-
\indexlibraryglobal{reflect_constant_string}%
6328-
\begin{itemdecl}
6329-
template<ranges::@\libconcept{input_range}@ R>
6330-
consteval info reflect_constant_string(R&& r);
6331-
\end{itemdecl}
6332-
6333-
\begin{itemdescr}
6334-
\pnum
6335-
Let \tcode{CharT} be \tcode{ranges::range_value_t<R>}.
6336-
6337-
\pnum
6338-
\mandates
6339-
\tcode{CharT} is one of
6340-
\tcode{char},
6341-
\tcode{wchar_t},
6342-
\tcode{char8_t},
6343-
\tcode{char16_t},
6344-
\tcode{char32_t}.
6345-
6346-
\pnum
6347-
Let $V$ be the pack of values of type \tcode{CharT}
6348-
whose elements are the corresponding elements of \tcode{r},
6349-
except that if \tcode{r} refers to a string literal object,
6350-
then $V$ does not include the trailing null terminator of \tcode{r}.
6351-
6352-
\pnum
6353-
Let $P$ be the template parameter object\iref{temp.param}
6354-
of type \tcode{const CharT[sizeof...(V) + 1]}
6355-
initialized with \tcode{\{$V$..., CharT()\}}.
6356-
6357-
\pnum
6358-
\returns
6359-
\tcode{\reflexpr{$P$}}.
6360-
6361-
\pnum
6362-
\begin{note}
6363-
$P$ is a potentially non-unique object\iref{intro.object}.
6364-
\end{note}
6365-
\end{itemdescr}
6366-
6367-
\indexlibraryglobal{reflect_constant_array}%
6368-
\begin{itemdecl}
6369-
template<ranges::@\libconcept{input_range}@ R>
6370-
consteval info reflect_constant_array(R&& r);
6371-
\end{itemdecl}
6372-
6373-
\begin{itemdescr}
6374-
\pnum
6375-
Let \tcode{T} be \tcode{ranges::range_value_t<R>}.
6376-
6377-
\pnum
6378-
\mandates
6379-
\tcode{T} is a structural type\iref{temp.param},
6380-
\tcode{is_constructible_v<T, ranges::range_reference_t<R>>} is \tcode{true}, and
6381-
\tcode{is_copy_constructible_v<T>} is \tcode{true}.
6382-
6383-
\pnum
6384-
Let $V$ be the pack of values of type \tcode{info}
6385-
of the same size as \tcode{r},
6386-
where the $i^\text{th}$ element is \tcode{reflect_constant($\tcode{e}_i$)},
6387-
where $\tcode{e}_i$ is the $i^\text{th}$ element of \tcode{r}.
6388-
6389-
\pnum
6390-
Let $P$ be
6391-
\begin{itemize}
6392-
\item
6393-
If \tcode{sizeof...($V$) > 0} is \tcode{true},
6394-
then the template parameter object\iref{temp.param}
6395-
of type \tcode{const T[\brk{}sizeof...(\brk{}$V$)]}
6396-
initialized with \tcode{\{[:$V$:]...\}}.
6397-
\item
6398-
Otherwise, the template parameter object
6399-
of type \tcode{const array<T, 0>}
6400-
initialized with \tcode{\{\}}.
6401-
\end{itemize}
6402-
6403-
\pnum
6404-
\returns
6405-
\tcode{\reflexpr{$P$}}.
6406-
6407-
\pnum
6408-
\throws
6409-
\tcode{meta::exception} unless
6410-
\tcode{reflect_constant(e)} is a constant subexpression
6411-
for every element \tcode{e} of \tcode{r}.
6412-
6413-
\pnum
6414-
\begin{note}
6415-
$P$ is a potentially non-unique object\iref{intro.object}.
6416-
\end{note}
6417-
\end{itemdescr}
6418-
64196413
\rSec2[meta.reflection.define.aggregate]{Reflection class definition generation}
64206414

64216415
\indexlibraryglobal{data_member_options}%

0 commit comments

Comments
 (0)