Skip to content

Commit a837ac6

Browse files
committed
[meta.reflection.annotation] Move to before [meta.reflection.extract]
Fixes NB US 87-156 (C++26 CD).
1 parent 3c0ac90 commit a837ac6

File tree

1 file changed

+114
-114
lines changed

1 file changed

+114
-114
lines changed

source/meta.tex

Lines changed: 114 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -3080,6 +3080,10 @@
30803080
consteval size_t alignment_of(info r);
30813081
consteval size_t bit_size_of(info r);
30823082

3083+
// \ref{meta.reflection.annotation}, annotation queries
3084+
consteval vector<info> annotations_of(info item);
3085+
consteval vector<info> annotations_of_with_type(info item, info type);
3086+
30833087
// \ref{meta.reflection.extract}, value extraction
30843088
template<class T>
30853089
consteval T extract(info);
@@ -3279,10 +3283,6 @@
32793283
consteval info variant_alternative(size_t index, info type);
32803284

32813285
consteval strong_ordering type_order(info type_a, info type_b);
3282-
3283-
// \ref{meta.reflection.annotation}, annotation reflection
3284-
consteval vector<info> annotations_of(info item);
3285-
consteval vector<info> annotations_of_with_type(info item, info type);
32863286
}
32873287
\end{codeblock}
32883288

@@ -5840,6 +5840,116 @@
58405840
\end{itemize}
58415841
\end{itemdescr}
58425842

5843+
\rSec2[meta.reflection.annotation]{Annotation queries}
5844+
5845+
\indexlibraryglobal{annotations_of}%
5846+
\begin{itemdecl}
5847+
consteval vector<info> annotations_of(info item);
5848+
\end{itemdecl}
5849+
5850+
\begin{itemdescr}
5851+
\pnum
5852+
Let $E$ be
5853+
\begin{itemize}
5854+
\item
5855+
the corresponding \grammarterm{base-specifier}
5856+
if \tcode{item} represents a direct base class relationship,
5857+
\item
5858+
otherwise, the entity represented by \tcode{item}.
5859+
\end{itemize}
5860+
5861+
\pnum
5862+
\returns
5863+
A \tcode{vector} containing all of the reflections $R$
5864+
representing each annotation applying to each declaration of $E$ that precedes either
5865+
some point in the evaluation context\iref{expr.const} or
5866+
a point immediately following the \grammarterm{class-specifier}
5867+
of the outermost class for which such a point is in a complete-class context.
5868+
For any two reflections $R_1$ and $R_2$ in the returned \tcode{vector},
5869+
if the annotation represented by $R_1$ precedes the annotation represented by $R_2$,
5870+
then $R_1$ appears before $R_2$.
5871+
If $R_1$ and $R_2$ represent annotations from the same translation unit $T$,
5872+
any element in the returned \tcode{vector} between $R_1$ and $R_2$
5873+
represents an annotation from $T$.
5874+
\begin{note}
5875+
The order in which two annotations appear is otherwise unspecified.
5876+
\end{note}
5877+
\begin{example}
5878+
\begin{codeblock}
5879+
[[=1]] void f();
5880+
[[=2, =3]] void g();
5881+
void g [[=4]] ();
5882+
5883+
static_assert(annotations_of(^^f).size() == 1);
5884+
static_assert(annotations_of(^^g).size() == 3);
5885+
static_assert([: constant_of(annotations_of(^^g)[0]) :] == 2);
5886+
static_assert(extract<int>(annotations_of(^^g)[1]) == 3);
5887+
static_assert(extract<int>(annotations_of(^^g)[2]) == 4);
5888+
5889+
struct Option { bool value; };
5890+
5891+
struct C {
5892+
[[=Option{true}]] int a;
5893+
[[=Option{false}]] int b;
5894+
};
5895+
5896+
static_assert(extract<Option>(annotations_of(^^C::a)[0]).value);
5897+
static_assert(!extract<Option>(annotations_of(^^C::b)[0]).value);
5898+
5899+
template<class T>
5900+
struct [[=42]] D { };
5901+
5902+
constexpr std::meta::info a1 = annotations_of(^^D<int>)[0];
5903+
constexpr std::meta::info a2 = annotations_of(^^D<char>)[0];
5904+
static_assert(a1 != a2);
5905+
static_assert(constant_of(a1) == constant_of(a2));
5906+
5907+
[[=1]] int x, y;
5908+
static_assert(annotations_of(^^x)[0] == annotations_of(^^y)[0]);
5909+
\end{codeblock}
5910+
\end{example}
5911+
5912+
\pnum
5913+
\throws
5914+
\tcode{meta::exception} unless
5915+
\tcode{item} represents a
5916+
type,
5917+
type alias,
5918+
variable,
5919+
function,
5920+
namespace,
5921+
enumerator,
5922+
direct base class relationship, or
5923+
non-static data member.
5924+
\end{itemdescr}
5925+
5926+
\indexlibraryglobal{annotations_of_with_type}%
5927+
\begin{itemdecl}
5928+
consteval vector<info> annotations_of_with_type(info item, info type);
5929+
\end{itemdecl}
5930+
5931+
\begin{itemdescr}
5932+
\pnum
5933+
\returns
5934+
A \tcode{vector} containing each element \tcode{e} of \tcode{annotations_of(item)}
5935+
where
5936+
\begin{codeblock}
5937+
remove_const(type_of(e)) == remove_const(type)
5938+
\end{codeblock}
5939+
is \tcode{true}, preserving their order.
5940+
5941+
\pnum
5942+
\throws
5943+
\tcode{meta::exception} unless
5944+
\begin{itemize}
5945+
\item
5946+
\tcode{annotations_of(item)} is a constant expression and
5947+
\item
5948+
\tcode{dealias(type)} represents a type that is complete
5949+
from some point in the evaluation context.
5950+
\end{itemize}
5951+
\end{itemdescr}
5952+
58435953
\rSec2[meta.reflection.extract]{Value extraction}
58445954

58455955
\pnum
@@ -6925,116 +7035,6 @@
69257035
represented by \tcode{dealias(t1)} and \tcode{dealias(t2)}, respectively.
69267036
\end{itemdescr}
69277037

6928-
\rSec2[meta.reflection.annotation]{Annotation reflection}
6929-
6930-
\indexlibraryglobal{annotations_of}%
6931-
\begin{itemdecl}
6932-
consteval vector<info> annotations_of(info item);
6933-
\end{itemdecl}
6934-
6935-
\begin{itemdescr}
6936-
\pnum
6937-
Let $E$ be
6938-
\begin{itemize}
6939-
\item
6940-
the corresponding \grammarterm{base-specifier}
6941-
if \tcode{item} represents a direct base class relationship,
6942-
\item
6943-
otherwise, the entity represented by \tcode{item}.
6944-
\end{itemize}
6945-
6946-
\pnum
6947-
\returns
6948-
A \tcode{vector} containing all of the reflections $R$
6949-
representing each annotation applying to each declaration of $E$ that precedes either
6950-
some point in the evaluation context\iref{expr.const} or
6951-
a point immediately following the \grammarterm{class-specifier}
6952-
of the outermost class for which such a point is in a complete-class context.
6953-
For any two reflections $R_1$ and $R_2$ in the returned \tcode{vector},
6954-
if the annotation represented by $R_1$ precedes the annotation represented by $R_2$,
6955-
then $R_1$ appears before $R_2$.
6956-
If $R_1$ and $R_2$ represent annotations from the same translation unit $T$,
6957-
any element in the returned \tcode{vector} between $R_1$ and $R_2$
6958-
represents an annotation from $T$.
6959-
\begin{note}
6960-
The order in which two annotations appear is otherwise unspecified.
6961-
\end{note}
6962-
\begin{example}
6963-
\begin{codeblock}
6964-
[[=1]] void f();
6965-
[[=2, =3]] void g();
6966-
void g [[=4]] ();
6967-
6968-
static_assert(annotations_of(^^f).size() == 1);
6969-
static_assert(annotations_of(^^g).size() == 3);
6970-
static_assert([: constant_of(annotations_of(^^g)[0]) :] == 2);
6971-
static_assert(extract<int>(annotations_of(^^g)[1]) == 3);
6972-
static_assert(extract<int>(annotations_of(^^g)[2]) == 4);
6973-
6974-
struct Option { bool value; };
6975-
6976-
struct C {
6977-
[[=Option{true}]] int a;
6978-
[[=Option{false}]] int b;
6979-
};
6980-
6981-
static_assert(extract<Option>(annotations_of(^^C::a)[0]).value);
6982-
static_assert(!extract<Option>(annotations_of(^^C::b)[0]).value);
6983-
6984-
template<class T>
6985-
struct [[=42]] D { };
6986-
6987-
constexpr std::meta::info a1 = annotations_of(^^D<int>)[0];
6988-
constexpr std::meta::info a2 = annotations_of(^^D<char>)[0];
6989-
static_assert(a1 != a2);
6990-
static_assert(constant_of(a1) == constant_of(a2));
6991-
6992-
[[=1]] int x, y;
6993-
static_assert(annotations_of(^^x)[0] == annotations_of(^^y)[0]);
6994-
\end{codeblock}
6995-
\end{example}
6996-
6997-
\pnum
6998-
\throws
6999-
\tcode{meta::exception} unless
7000-
\tcode{item} represents a
7001-
type,
7002-
type alias,
7003-
variable,
7004-
function,
7005-
namespace,
7006-
enumerator,
7007-
direct base class relationship, or
7008-
non-static data member.
7009-
\end{itemdescr}
7010-
7011-
\indexlibraryglobal{annotations_of_with_type}%
7012-
\begin{itemdecl}
7013-
consteval vector<info> annotations_of_with_type(info item, info type);
7014-
\end{itemdecl}
7015-
7016-
\begin{itemdescr}
7017-
\pnum
7018-
\returns
7019-
A \tcode{vector} containing each element \tcode{e} of \tcode{annotations_of(item)}
7020-
where
7021-
\begin{codeblock}
7022-
remove_const(type_of(e)) == remove_const(type)
7023-
\end{codeblock}
7024-
is \tcode{true}, preserving their order.
7025-
7026-
\pnum
7027-
\throws
7028-
\tcode{meta::exception} unless
7029-
\begin{itemize}
7030-
\item
7031-
\tcode{annotations_of(item)} is a constant expression and
7032-
\item
7033-
\tcode{dealias(type)} represents a type that is complete
7034-
from some point in the evaluation context.
7035-
\end{itemize}
7036-
\end{itemdescr}
7037-
70387038
\rSec1[ratio]{Compile-time rational arithmetic}
70397039

70407040
\rSec2[ratio.general]{General}

0 commit comments

Comments
 (0)