Skip to content

Commit 3141300

Browse files
committed
P2996R13 Reflection for C++26
1 parent 2e12f5e commit 3141300

File tree

6 files changed

+3560
-19
lines changed

6 files changed

+3560
-19
lines changed

source/compatibility.tex

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@
1313

1414
\rSec2[diff.cpp23.lex]{\ref{lex}: Lexical conventions}
1515

16+
\diffref{lex.operators}
17+
\change
18+
New operator \tcode{\caret\caret}.
19+
\rationale
20+
Required for new features.
21+
\effect
22+
Valid \CppXXIII{} that contains two consecutive \tcode{\caret} tokens
23+
can be ill-formed in this revision of \Cpp{}.
24+
\begin{example}
25+
\begin{codeblock}
26+
struct C { int operator^(int); };
27+
int operator^(int (C::*p)(int), C);
28+
int i = &C::operator^^C{}; // ill-formed; previously well-formed
29+
\end{codeblock}
30+
\end{example}
31+
1632
\diffref{lex.key}
1733
\change
1834
New keywords.
@@ -148,6 +164,23 @@
148164
\end{codeblock}
149165
\end{example}
150166

167+
\diffref{dcl.attr.grammar}
168+
\change
169+
New token \tcode{:]}.
170+
\rationale
171+
Required for new features.
172+
\effect
173+
Valid \CppXXIII{} that contained an \grammarterm{attribute-specifier}
174+
with an \grammarterm{attribute-using-prefix}
175+
but no attributes and no whitespace
176+
is ill-formed in this revision of \Cpp{}.
177+
\begin{example}
178+
\begin{codeblock}
179+
struct [[using CC:]] C; // ill-formed; previously well-formed
180+
struct [[using DD: ]] D; // OK
181+
\end{codeblock}
182+
\end{example}
183+
151184
\rSec2[diff.cpp23.temp]{\ref{temp}: templates}
152185

153186
\diffref{temp.constr}
@@ -221,6 +254,8 @@
221254
\libheaderref{hive},
222255
\libheaderrefx{inplace_vector}{inplace.vector.syn},
223256
\libheaderref{linalg},
257+
%FIXME: \libheaderref{meta} after renaming to meta.syn
258+
\libheaderrefx{meta}{meta.type.synop},
224259
\libheaderref{rcu},
225260
\libheaderref{simd},
226261
\libheaderref{stdbit.h},

source/lib-intro.tex

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@
368368
and also define the function as deleted.
369369
\end{example}
370370

371+
\item
372+
\constantwhen
373+
the conditions that are required for a call to the function
374+
to be a constant subexpression\iref{defns.const.subexpr}.
375+
371376
\item
372377
\expects
373378
conditions that the function assumes to hold whenever it is called;
@@ -454,6 +459,7 @@
454459
Next, the semantics of the code sequence are determined by the
455460
\Fundescx{Constraints},
456461
\Fundescx{Mandates},
462+
\Fundescx{Constant When},
457463
\Fundescx{Preconditions},
458464
\Fundescx{Hardened preconditions},
459465
\Fundescx{Effects},
@@ -1223,8 +1229,8 @@
12231229
\tcode{<flat_map>} \\
12241230
\tcode{<flat_set>} \\
12251231
\tcode{<format>} \\
1226-
\tcode{<forward_list>} \\
12271232
\columnbreak
1233+
\tcode{<forward_list>} \\
12281234
\tcode{<fstream>} \\
12291235
\tcode{<functional>} \\
12301236
\tcode{<future>} \\
@@ -1248,8 +1254,9 @@
12481254
\tcode{<mdspan>} \\
12491255
\tcode{<memory>} \\
12501256
\tcode{<memory_resource>} \\
1251-
\tcode{<mutex>} \\
12521257
\columnbreak
1258+
\tcode{<meta>} \\
1259+
\tcode{<mutex>} \\
12531260
\tcode{<new>} \\
12541261
\tcode{<numbers>} \\
12551262
\tcode{<numeric>} \\
@@ -1271,9 +1278,9 @@
12711278
\tcode{<span>} \\
12721279
\tcode{<spanstream>} \\
12731280
\tcode{<sstream>} \\
1281+
\columnbreak
12741282
\tcode{<stack>} \\
12751283
\tcode{<stacktrace>} \\
1276-
\columnbreak
12771284
\tcode{<stdexcept>} \\
12781285
\tcode{<stdfloat>} \\
12791286
\tcode{<stop_token>} \\
@@ -3082,6 +3089,26 @@
30823089
either a standard library non-static member function\iref{member.functions}
30833090
or an instantiation of a standard library member function template.
30843091

3092+
\pnum
3093+
Let \tcode{\placeholder{F}} denote
3094+
a standard library function or function template.
3095+
Unless \tcode{\placeholder{F}} is designated an addressable function,
3096+
it is unspecified if or how
3097+
a reflection value designating the associated entity can be formed.
3098+
%FIXME: Why is this not an example, but a note that begins with "For example"?
3099+
\begin{note}
3100+
For example, it is possible that \tcode{std::meta::members_of}
3101+
will not return reflections of standard library functions
3102+
that an implementation handles through an extra-linguistic mechanism.
3103+
\end{note}
3104+
3105+
\pnum
3106+
Let \tcode{\placeholder{F}} denote
3107+
a standard library class or class template specialization.
3108+
It is unspecified if or how
3109+
a reflection value can be formed to any private member of \tcode{\placeholder{F}},
3110+
or what the names of such members may be.
3111+
30853112
\pnum
30863113
A translation unit shall not declare namespace \tcode{std} to be an inline namespace\iref{namespace.def}.
30873114

source/macros.tex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@
363363
\newcommand{\required}{\Fundesc{Required behavior}}
364364
\newcommand{\constraints}{\Fundesc{Constraints}}
365365
\newcommand{\mandates}{\Fundesc{Mandates}}
366+
\newcommand{\constantwhen}{\Fundesc{Constant When}}
366367
\newcommand{\expects}{\Fundesc{Preconditions}}
367368
\newcommand{\hardexpects}{\Fundesc{Hardened preconditions}}
368369
\newcommand{\effects}{\Fundesc{Effects}}
@@ -465,6 +466,10 @@
465466
\newcommand{\unspecuniqtype}{\UNSP{unspecified unique type}}
466467
\newcommand{\unspecalloctype}{\UNSP{unspecified allocator type}}
467468

469+
%% Convenience macro for double carets in expressions,
470+
%% particularly within \tcode.
471+
\newcommand{\reflexpr}[1]{\caret\caret#1}
472+
468473
%% Manual insertion of italic corrections, for aligning in the presence
469474
%% of the above annotations.
470475
\newlength{\itcorrwidth}

0 commit comments

Comments
 (0)