Skip to content

Commit 3b2da27

Browse files
committed
[meta.reflection] Move examples to the end of their respective section
Fixes NB US 83-152 (C++26 NB).
1 parent cc53316 commit 3b2da27

File tree

1 file changed

+93
-73
lines changed

1 file changed

+93
-73
lines changed

source/meta.tex

Lines changed: 93 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -4072,17 +4072,6 @@
40724072
Otherwise, \tcode{r} represents a variable;
40734073
a reflection of the object declared by that variable.
40744074
\end{itemize}
4075-
\begin{example}
4076-
\begin{codeblock}
4077-
int x;
4078-
int& y = x;
4079-
4080-
static_assert(^^x != ^^y); // OK, \tcode{r} and \tcode{y} are different variables so their
4081-
// reflections compare different
4082-
static_assert(object_of(^^x) == object_of(^^y)); // OK, because \tcode{y} is a reference
4083-
// to \tcode{x}, their underlying objects are the same
4084-
\end{codeblock}
4085-
\end{example}
40864075

40874076
\pnum
40884077
\throws
@@ -4102,6 +4091,19 @@
41024091
currently under evaluation.
41034092
\end{itemize}
41044093
\end{itemize}
4094+
4095+
\pnum
4096+
\begin{example}
4097+
\begin{codeblock}
4098+
int x;
4099+
int& y = x;
4100+
4101+
static_assert(^^x != ^^y); // OK, \tcode{r} and \tcode{y} are different variables so their
4102+
// reflections compare different
4103+
static_assert(object_of(^^x) == object_of(^^y)); // OK, because \tcode{y} is a reference
4104+
// to \tcode{x}, their underlying objects are the same
4105+
\end{codeblock}
4106+
\end{example}
41054107
\end{itemdescr}
41064108

41074109
\indexlibraryglobal{constant_of}%
@@ -4126,6 +4128,15 @@
41264128
return reflect_constant([: @$R$@ :]);
41274129
}
41284130
\end{codeblock}
4131+
4132+
\pnum
4133+
\throws
4134+
\tcode{meta::exception} unless
4135+
either \tcode{r} represents an annotation or
4136+
\tcode{[: $R$ :]} is a valid
4137+
\grammarterm{splice-expression}\iref{expr.prim.splice}.
4138+
4139+
\pnum
41294140
\begin{example}
41304141
\begin{codeblock}
41314142
constexpr int x = 0;
@@ -4155,13 +4166,6 @@
41554166
constexpr info r = constant_of(fn()); // error: \tcode{x} is outside its lifetime
41564167
\end{codeblock}
41574168
\end{example}
4158-
4159-
\pnum
4160-
\throws
4161-
\tcode{meta::exception} unless
4162-
either \tcode{r} represents an annotation or
4163-
\tcode{[: $R$ :]} is a valid
4164-
\grammarterm{splice-expression}\iref{expr.prim.splice}.
41654169
\end{itemdescr}
41664170

41674171
\indexlibraryglobal{is_public}%
@@ -4464,6 +4468,8 @@
44644468
\tcode{true} if \tcode{dealias(r)} represents a type that is enumerable
44654469
from some point in the evaluation context.
44664470
Otherwise, \tcode{false}.
4471+
4472+
\pnum
44674473
\begin{example}
44684474
\begin{codeblock}
44694475
class S;
@@ -4864,6 +4870,13 @@
48644870
Otherwise, \tcode{\reflexpr{$E$}}.
48654871
\end{itemize}
48664872
\end{itemize}
4873+
4874+
\pnum
4875+
\throws
4876+
\tcode{meta::exception} unless
4877+
\tcode{has_parent(r)} is \tcode{true}.
4878+
4879+
\pnum
48674880
\begin{example}
48684881
\begin{codeblock}
48694882
struct I { };
@@ -4887,11 +4900,6 @@
48874900
static_assert(parent_of(^^F::A) == ^^F::N);
48884901
\end{codeblock}
48894902
\end{example}
4890-
4891-
\pnum
4892-
\throws
4893-
\tcode{meta::exception} unless
4894-
\tcode{has_parent(r)} is \tcode{true}.
48954903
\end{itemdescr}
48964904

48974905
\indexlibraryglobal{dealias}%
@@ -4903,6 +4911,13 @@
49034911
\pnum
49044912
\returns
49054913
A reflection representing the underlying entity of what \tcode{r} represents.
4914+
4915+
\pnum
4916+
\throws
4917+
\tcode{meta::exception} unless
4918+
\tcode{r} represents an entity.
4919+
4920+
\pnum
49064921
\begin{example}
49074922
\begin{codeblock}
49084923
using X = int;
@@ -4912,11 +4927,6 @@
49124927
static_assert(dealias(^^Y) == ^^int);
49134928
\end{codeblock}
49144929
\end{example}
4915-
4916-
\pnum
4917-
\throws
4918-
\tcode{meta::exception} unless
4919-
\tcode{r} represents an entity.
49204930
\end{itemdescr}
49214931

49224932
\indexlibraryglobal{has_template_arguments}%
@@ -4994,6 +5004,13 @@
49945004
Otherwise, $R$ is a reflection representing the value of $A$.
49955005
\end{itemize}
49965006
\end{itemize}
5007+
5008+
\pnum
5009+
\throws
5010+
\tcode{meta::exception} unless
5011+
\tcode{has_template_arguments(r)} is \tcode{true}.
5012+
5013+
\pnum
49975014
\begin{example}
49985015
\begin{codeblock}
49995016
template<class T, class U = T> struct Pair { };
@@ -5019,11 +5036,6 @@
50195036
static_assert(template_arguments_of(T)[3] == ^^PairPtr);
50205037
\end{codeblock}
50215038
\end{example}
5022-
5023-
\pnum
5024-
\throws
5025-
\tcode{meta::exception} unless
5026-
\tcode{has_template_arguments(r)} is \tcode{true}.
50275039
\end{itemdescr}
50285040

50295041
\indexlibraryglobal{parameters_of}%
@@ -5243,6 +5255,16 @@
52435255
is \tcode{\exposid{ctx-scope}($S$)},
52445256
where $S$ is the immediate scope of \tcode{\exposid{eval-point}($P$)}
52455257
and $P$ is the point at which the invocation of \tcode{current} lexically appears.
5258+
5259+
\pnum
5260+
\remarks
5261+
\tcode{current} is not an addressable function\iref{namespace.std}.
5262+
An invocation of \tcode{current} that appears at a program point $P$
5263+
is value-dependent\iref{temp.dep.constexpr}
5264+
if \tcode{\exposid{eval-point}\brk{}(\brk{}$P$)} is enclosed by a scope
5265+
corresponding to a templated entity.
5266+
5267+
\pnum
52465268
\begin{example}
52475269
\begin{codeblock}
52485270
struct A {
@@ -5284,14 +5306,6 @@
52845306
}
52855307
\end{codeblock}
52865308
\end{example}
5287-
5288-
\pnum
5289-
\remarks
5290-
\tcode{current} is not an addressable function\iref{namespace.std}.
5291-
An invocation of \tcode{current} that appears at a program point $P$
5292-
is value-dependent\iref{temp.dep.constexpr}
5293-
if \tcode{\exposid{eval-point}\brk{}(\brk{}$P$)} is enclosed by a scope
5294-
corresponding to a templated entity.
52955309
\end{itemdescr}
52965310

52975311
\begin{itemdecl}
@@ -5411,6 +5425,20 @@
54115425
The definitions of when a class member or base class is accessible from a point $P$
54125426
do not consider whether a declaration of that entity is reachable from $P$.
54135427
\end{note}
5428+
5429+
\pnum
5430+
\throws
5431+
\tcode{meta::exception} if
5432+
\begin{itemize}
5433+
\item
5434+
\tcode{r} represents a class member
5435+
for which \tcode{\exposid{PARENT-CLS}(r)} is an incomplete class or
5436+
\item
5437+
\tcode{r} represents a direct base class relationship $(D, B)$
5438+
for which $D$ is incomplete.
5439+
\end{itemize}
5440+
5441+
\pnum
54145442
\begin{example}
54155443
\begin{codeblock}
54165444
consteval access_context fn() {
@@ -5429,18 +5457,6 @@
54295457
static_assert(is_accessible(Cls::r, access_context::unchecked())); // OK
54305458
\end{codeblock}
54315459
\end{example}
5432-
5433-
\pnum
5434-
\throws
5435-
\tcode{meta::exception} if
5436-
\begin{itemize}
5437-
\item
5438-
\tcode{r} represents a class member
5439-
for which \tcode{\exposid{PARENT-CLS}(r)} is an incomplete class or
5440-
\item
5441-
\tcode{r} represents a direct base class relationship $(D, B)$
5442-
for which $D$ is incomplete.
5443-
\end{itemize}
54445460
\end{itemdescr}
54455461

54465462
\indexlibraryglobal{has_inaccessible_nonstatic_data_members}%
@@ -5605,6 +5621,15 @@
56055621
Implicitly-declared special members
56065622
appear after any user-declared members\iref{special}.
56075623
\end{note}
5624+
5625+
\pnum
5626+
\throws
5627+
\tcode{meta::exception} unless
5628+
\tcode{dealias(r)} is a reflection representing either
5629+
a class type that is complete from some point in the evaluation context
5630+
or a namespace.
5631+
5632+
\pnum
56085633
\begin{example}
56095634
\begin{codeblock}
56105635
// TU1
@@ -5639,13 +5664,6 @@
56395664
// representing \tcode{S::I}
56405665
\end{codeblock}
56415666
\end{example}
5642-
5643-
\pnum
5644-
\throws
5645-
\tcode{meta::exception} unless
5646-
\tcode{dealias(r)} is a reflection representing either
5647-
a class type that is complete from some point in the evaluation context
5648-
or a namespace.
56495667
\end{itemdescr}
56505668

56515669
\indexlibraryglobal{bases_of}%
@@ -5969,6 +5987,21 @@
59695987
\begin{note}
59705988
The order in which two annotations appear is otherwise unspecified.
59715989
\end{note}
5990+
5991+
\pnum
5992+
\throws
5993+
\tcode{meta::exception} unless
5994+
\tcode{item} represents a
5995+
type,
5996+
type alias,
5997+
variable,
5998+
function,
5999+
namespace,
6000+
enumerator,
6001+
direct base class relationship, or
6002+
non-static data member.
6003+
6004+
\pnum
59726005
\begin{example}
59736006
\begin{codeblock}
59746007
[[=1]] void f();
@@ -6003,19 +6036,6 @@
60036036
static_assert(annotations_of(^^x)[0] == annotations_of(^^y)[0]);
60046037
\end{codeblock}
60056038
\end{example}
6006-
6007-
\pnum
6008-
\throws
6009-
\tcode{meta::exception} unless
6010-
\tcode{item} represents a
6011-
type,
6012-
type alias,
6013-
variable,
6014-
function,
6015-
namespace,
6016-
enumerator,
6017-
direct base class relationship, or
6018-
non-static data member.
60196039
\end{itemdescr}
60206040

60216041
\indexlibraryglobal{annotations_of_with_type}%

0 commit comments

Comments
 (0)