diff --git a/source/meta.tex b/source/meta.tex index 880f84f533..b9758279b1 100644 --- a/source/meta.tex +++ b/source/meta.tex @@ -2599,6 +2599,9 @@ namespace std::meta { using info = decltype(^^::); + // \ref{meta.reflection.exception}, class \tcode{exception} + class exception; + // \ref{meta.reflection.operators}, operator representations enum class operators { @\seebelow@; @@ -3102,6 +3105,128 @@ \end{note} \end{itemdescr} +\rSec2[meta.reflection.exception]{Class \tcode{exception}} + +\indexlibraryglobal{exception}% +\begin{codeblock} +namespace std::meta { + class exception : public std::exception { + private: + optional @\exposidnc{what_}@; // \expos + u8string @\exposidnc{u8what_}@; // \expos + info @\exposidnc{from_}@; // \expos + source_location @\exposidnc{where_}@; // \expos + + public: + consteval exception(u8string_view what, info from, + source_location where = source_location::current()) noexcept; + + consteval exception(string_view what, info from, + source_location where = source_location::current()) noexcept; + + exception(const exception&) = default; + exception(exception&&) = default; + + exception& operator=(const exception&) = default; + exception& operator=(exception&&) = default; + + constexpr const char* what() const noexcept override; + consteval u8string_view u8what() const noexcept; + consteval info from() const noexcept; + consteval source_location where() const noexcept; + }; +} +\end{codeblock} + +\pnum +Reflection functions throw exceptions of type \tcode{meta::exception} +to signal an error. +\tcode{meta::exception} is a consteval-only type. + +\indexlibraryctor{exception}% +\begin{itemdecl} +consteval exception(u8string_view what, info from, + source_location where = source_location::current()) noexcept; +\end{itemdecl} +\begin{itemdescr} +\pnum +\effects +Initializes +\exposid{u8what_} with \tcode{what}, +\exposid{from_} with \tcode{from}, and +\exposid{where_} with \tcode{where}. +If \tcode{what} can be represented in the ordinary literal encoding, +initializes \exposid{what_} with \tcode{what}, +transcoded from UTF-8 to the ordinary literal encoding. +Otherwhise, \exposid{what_} is value-initialized. +\end{itemdescr} + +\indexlibraryctor{exception}% +\begin{itemdecl} +consteval exception(string_view what, info from, + source_location where = source_location::current()) noexcept; +\end{itemdecl} +\begin{itemdescr} +\pnum +\constantwhen +\tcode{what} designates a sequence of characters +that can be encoded in UTF-8. + +\pnum +\effects +Initializes +\exposid{what_} with \tcode{what}, +\exposid{u8what_} with \tcode{what} +transcoded from the ordinary literal encoding to UTF-8, +%FIXME: Oxford comma before "and" +\exposid{from_} with \tcode{from} and +\exposid{where_} with \tcode{where}. +\end{itemdescr} + +\indexlibrarymember{what}{exception}% +\begin{itemdecl} +constexpr const char* what() const noexcept override; +\end{itemdecl} +\begin{itemdescr} +\pnum +\constantwhen +\tcode{\exposid{what_}.has_value()} is \tcode{true}. + +\pnum +\returns +\tcode{\exposid{what_}->c_str()}. +\end{itemdescr} + +\indexlibrarymember{u8what}{exception}% +\begin{itemdecl} +consteval u8string_view what() const noexcept; +\end{itemdecl} +\begin{itemdescr} +\pnum +\returns +\exposid{u8what_}. +\end{itemdescr} + +\indexlibrarymember{from}{exception}% +\begin{itemdecl} +consteval info from() const noexcept; +\end{itemdecl} +\begin{itemdescr} +\pnum +\returns +\exposid{from_}. +\end{itemdescr} + +\indexlibrarymember{where}{exception}% +\begin{itemdecl} +consteval source_location where() const noexcept; +\end{itemdecl} +\begin{itemdescr} +\pnum +\returns +\exposid{where_}. +\end{itemdescr} + \rSec2[meta.reflection.operators]{Operator representations} \begin{itemdecl} @@ -3179,15 +3304,16 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\constantwhen -\tcode{r} represents an operator function or operator function template. - \pnum \returns The value of the enumerator from the \tcode{operators} whose corresponding \grammarterm{operator-function-id} is the unqualified name of the entity represented by \tcode{r}. + +\pnum +\throws +\tcode{meta::exception} unless +\tcode{r} represents an operator function or operator function template. \end{itemdescr} \indexlibraryglobal{symbol_of}% @@ -3198,15 +3324,16 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\constantwhen -The value of \tcode{op} corresponds to one of the enumerators in \tcode{operators}. - \pnum \returns A \tcode{string_view} or \tcode{u8string_view} containing the characters of the operator symbol name corresponding to \tcode{op}, respectively encoded with the ordinary literal encoding or with UTF-8. + +\pnum +\throws +\tcode{meta::exception} unless +the value of \tcode{op} corresponds to one of the enumerators in \tcode{operators}. \end{itemdescr} \rSec2[meta.reflection.names]{Reflection names and locations} @@ -3330,12 +3457,6 @@ Let $E$ be UTF-8 for \tcode{u8identifier_of}, and otherwise the ordinary literal encoding. -\pnum -\constantwhen -\tcode{has_identifier(r)} is \tcode{true} -and the identifier that would be returned (see below) -is representable by $E$. - \pnum \returns An \ntmbs{}, encoded with $E$, @@ -3369,6 +3490,13 @@ a \tcode{string_view} or \tcode{u8string_view}, respectively, containing the identifier \tcode{\placeholder{N}}. \end{itemize} + +\pnum +\throws +\tcode{meta::exception} unless +\tcode{has_identifier(r)} is \tcode{true} +and the identifier that would be returned (see below) +is representable by $E$. \end{itemdescr} \indexlibraryglobal{display_string_of}% @@ -3448,10 +3576,6 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\constantwhen -\tcode{\exposid{has-type}(r)} is \tcode{true}. - \pnum \returns \begin{itemize} @@ -3493,6 +3617,11 @@ Otherwise, for a data member description $(T, N, A, W, \mathit{NUA})$\iref{class.mem.general}, a reflection of the type $T$. \end{itemize} + +\pnum +\throws +\tcode{meta::exception} unless +\tcode{\exposid{has-type}(r)} is \tcode{true}. \end{itemdescr} \indexlibraryglobal{object_of}% @@ -3501,24 +3630,6 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\constantwhen -\tcode{r} is a reflection representing either -\begin{itemize} -\item - an object with static storage duration\iref{basic.stc.general}, or -\item - a variable that either declares or refers to such an object, - and if that variable is a reference $R$, then either - \begin{itemize} - \item - $R$ is usable in constant expressions\iref{expr.const}, or - \item - the lifetime of $R$ began within the core constant expression - currently under evaluation. - \end{itemize} -\end{itemize} - \pnum \returns \begin{itemize} @@ -3543,6 +3654,25 @@ // to \tcode{x}, their underlying objects are the same \end{codeblock} \end{example} + +\pnum +\throws +\tcode{meta::exception} unless +\tcode{r} is a reflection representing either +\begin{itemize} +\item + an object with static storage duration\iref{basic.stc.general}, or +\item + a variable that either declares or refers to such an object, + and if that variable is a reference $R$, then either + \begin{itemize} + \item + $R$ is usable in constant expressions\iref{expr.const}, or + \item + the lifetime of $R$ began within the core constant expression + currently under evaluation. + \end{itemize} +\end{itemize} \end{itemdescr} \indexlibraryglobal{constant_of}% @@ -3557,12 +3687,6 @@ If \tcode{r} represents an annotation, then let $C$ be its underlying constant. -\pnum -\constantwhen -Either \tcode{r} represents an annotation or -\tcode{[: $R$ :]} is a valid -\grammarterm{splice-expression}\iref{expr.prim.splice}. - \pnum \effects Equivalent to: @@ -3602,6 +3726,13 @@ constexpr info r = constant_of(fn()); // error: \tcode{x} is outside its lifetime \end{codeblock} \end{example} + +\pnum +\throws +\tcode{meta::exception} unless +either \tcode{r} represents an annotation or +\tcode{[: $R$ :]} is a valid +\grammarterm{splice-expression}\iref{expr.prim.splice}. \end{itemdescr} \indexlibraryglobal{is_public}% @@ -4259,10 +4390,6 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\constantwhen -\tcode{has_parent(r)} is \tcode{true}. - \pnum \returns \begin{itemize} @@ -4321,6 +4448,11 @@ static_assert(parent_of(^^F::A) == ^^F::N); \end{codeblock} \end{example} + +\pnum +\throws +\tcode{meta::exception} unless +\tcode{has_parent(r)} is \tcode{true}. \end{itemdescr} \indexlibraryglobal{delias}% @@ -4329,10 +4461,6 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\constantwhen -\tcode{r} represents an entity. - \pnum \returns A reflection representing the underlying entity of what \tcode{r} represents. @@ -4361,6 +4489,11 @@ class template, or an alias template. Otherwise, \tcode{false}. + +\pnum +\throws +\tcode{meta::exception} unless +\tcode{r} represents an entity. \end{itemdescr} \indexlibraryglobal{template_of}% @@ -4369,13 +4502,14 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\constantwhen -\tcode{has_template_arguments(r)} is \tcode{true}. - \pnum \returns A reflection of the template of the specialization represented by \tcode{r}. + +\pnum +\throws +\tcode{meta::exception} unless +\tcode{has_template_arguments(r)} is \tcode{true}. \end{itemdescr} \indexlibraryglobal{template_arguments_of}% @@ -4384,10 +4518,6 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\constantwhen -\tcode{has_template_arguments(r)} is \tcode{true}. - \pnum \returns A \tcode{vector} containing reflections @@ -4450,6 +4580,11 @@ static_assert(template_arguments_of(T)[3] == ^^PairPtr); \end{codeblock} \end{example} + +\pnum +\throws +\tcode{meta::exception} unless +\tcode{has_template_arguments(r)} is \tcode{true}. \end{itemdescr} \indexlibraryglobal{parameters_of}% @@ -4458,10 +4593,6 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\constantwhen -\tcode{r} represents a function or a function type. - \pnum \returns \begin{itemize} @@ -4475,6 +4606,11 @@ in parameter-type-list\iref{dcl.fct} of $T$, in the order in which they appear in the parameter-type-list. \end{itemize} + +\pnum +\throws +\tcode{meta::exception} unless +\tcode{r} represents a function or a function type. \end{itemdescr} \indexlibraryglobal{variable_of}% @@ -4484,7 +4620,12 @@ \begin{itemdescr} \pnum -\constantwhen +\returns +The reflection of the parameter variable corresponding to \tcode{r}. + +\pnum +\throws +\tcode{meta::exception} unless \begin{itemize} \item \tcode{r} represents a parameter of a function $F$ and @@ -4494,10 +4635,6 @@ is the function parameter scope\iref{basic.scope.param} associated with $F$. \end{itemize} - -\pnum -\returns -The reflection of the parameter variable corresponding to \tcode{r}. \end{itemdescr} \indexlibraryglobal{return_type_of}% @@ -4506,16 +4643,17 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\constantwhen -Either \tcode{r} represents a function -and \tcode{\exposid{has-type}(r)} is \tcode{true} -or \tcode{r} represents a function type. - \pnum \returns The reflection of the return type of the function or function type represented by \tcode{r}. + +\pnum +\throws +\tcode{meta::exception} +either \tcode{r} represents a function +and \tcode{\exposid{has-type}(r)} is \tcode{true} +or \tcode{r} represents a function type. \end{itemdescr} \rSec2[meta.reflection.access.context]{Access control context} @@ -4744,15 +4882,16 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\constantwhen -\tcode{cls} is either the null reflection -or a reflection of a complete class type. - \pnum \returns An \tcode{access_context} whose scope is \tcode{this->scope()} and whose designating class is \tcode{cls}. + +\pnum +\throws +\tcode{meta::exception} unless +\tcode{cls} is either the null reflection +or a reflection of a complete class type. \end{itemdescr} \rSec2[meta.reflection.access.queries]{Member accessibility queries} @@ -4770,17 +4909,6 @@ \item Otherwise, \tcode{\exposid{PARENT-CLS}(parent_of(r))}. \end{itemize} -\pnum -\constantwhen -\begin{itemize} -\item - \tcode{r} does not represent a class member - for which \tcode{\exposid{PARENT-CLS}(r)} is an incomplete class and -\item - \tcode{r} does not represent a direct base class relationship $(D, B)$ - for which $D$ is incomplete. -\end{itemize} - \pnum Let \tcode{\exposid{DESIGNATING-CLS}(r, ctx)} be: \begin{itemize} @@ -4862,6 +4990,18 @@ static_assert(is_accessible(Cls::r, access_context::unchecked())); // OK \end{codeblock} \end{example} + +\pnum +\throws +\tcode{meta::exception} if +\begin{itemize} +\item + \tcode{r} represents a class member + for which \tcode{\exposid{PARENT-CLS}(r)} is an incomplete class or +\item + \tcode{r} represents a direct base class relationship $(D, B)$ + for which $D$ is incomplete. +\end{itemize} \end{itemdescr} \indexlibraryglobal{has_inaccessible_nonstatic_data_members}% @@ -4871,7 +5011,14 @@ \begin{itemdescr} \pnum -\constantwhen +\returns +\tcode{true} if \tcode{is_accessible($R$, ctx)} is \tcode{false} +for any $R$ in \tcode{nonstatic_data_members_of(\brk{}r, access_context\brk{}::unchecked())}. +Otherwise, \tcode{false}. + +\pnum +\throws +\tcode{meta::exception} unless \begin{itemize} \item \tcode{nonstatic_data_members_of(\brk{}r, access_context::\brk{}unchecked())} @@ -4879,12 +5026,6 @@ \item \tcode{r} does not represent a closure type. \end{itemize} - -\pnum -\returns -\tcode{true} if \tcode{is_accessible($R$, ctx)} is \tcode{false} -for any $R$ in \tcode{nonstatic_data_members_of(\brk{}r, access_context\brk{}::unchecked())}. -Otherwise, \tcode{false}. \end{itemdescr} \begin{itemdecl} @@ -4892,16 +5033,17 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\constantwhen -\tcode{bases_of(r, access:context::unchecked())} -is a constant subexpression. - \pnum \returns \tcode{true} if \tcode{is_accessible($R$, ctx)} is \tcode{false} for any $R$ in \tcode{bases_of(\brk{}r, access_context::\brk{}unchecked())}. Otherwise, \tcode{false}. + +\pnum +\throws +\tcode{meta::exception} unless +\tcode{bases_of(r, access:context::unchecked())} +is a constant subexpression. \end{itemdescr} \indexlibraryglobal{has_inaccessible_subobjects}% @@ -4926,12 +5068,6 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\constantwhen -\tcode{dealias(r)} is a reflection representing either -a class type that is complete from some point in the evaluation context -or a namespace. - \pnum A declaration $D$ \term{members-of-precedes} a point $P$ if $D$ precedes either $P$ @@ -5064,6 +5200,13 @@ // representing \tcode{S::I} \end{codeblock} \end{example} + +\pnum +\throws +\tcode{meta::exception} unless +\tcode{dealias(r)} is a reflection representing either +a class type that is complete from some point in the evaluation context +or a namespace. \end{itemdescr} \indexlibraryglobal{bases_of}% @@ -5072,11 +5215,6 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\constantwhen -\tcode{dealias(type)} represents a class type -that is complete from some point in the evaluation context. - \pnum \returns Let $C$ be the class represented by \tcode{dealias(type)}. @@ -5085,24 +5223,31 @@ of $C$ such that \tcode{is_accessible(\brk{}\reflexpr{B}, txt)} is \tcode{true}. The direct base class relationships appear in the order in which the corresponding base classes appear in the \grammarterm{base-specifier-list} of $C$. -\end{itemdescr} -\indexlibraryglobal{static_data_members_of}% -\begin{itemdecl} -consteval vector static_data_members_of(info type, access_context ctx); -\end{itemdecl} - -\begin{itemdescr} \pnum -\constantwhen +\throws +\tcode{meta::exception} unless \tcode{dealias(type)} represents a class type that is complete from some point in the evaluation context. +\end{itemdescr} + +\indexlibraryglobal{static_data_members_of}% +\begin{itemdecl} +consteval vector static_data_members_of(info type, access_context ctx); +\end{itemdecl} +\begin{itemdescr} \pnum \returns A \tcode{vector} containing each element \tcode{e} of \tcode{members_of(type, ctx)} such that \tcode{is_variable(e)} is \tcode{true}, preserving their order. + +\pnum +\throws +\tcode{meta::exception} unless +\tcode{dealias(type)} represents a class type +that is complete from some point in the evaluation context. \end{itemdescr} @@ -5112,16 +5257,17 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\constantwhen -\tcode{dealias(type)} represents a class type -that is complete from some point in the evaluation context. - \pnum \returns A \tcode{vector} containing each element \tcode{e} of \tcode{members_of(type, ctx)} such that \tcode{is_nonstatic_data_members_of(e)} is \tcode{true}, preserving their order. + +\pnum +\throws +\tcode{meta::exception} unless +\tcode{dealias(type)} represents a class type +that is complete from some point in the evaluation context. \end{itemdescr} \indexlibraryglobal{subobjects_of}% @@ -5130,16 +5276,17 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\constantwhen -\tcode{dealias(type)} represents a class type -that is complete from some point in the evaluation context. - \pnum \returns A \tcode{vector} containing each element of \tcode{bases_of(type, ctx)} followed by each element of \tcode{non\-static_data_mem\-bers_of(\brk{}type,\brk{} ctx)}, preserving their order. + +\pnum +\throws +\tcode{meta::exception} unless +\tcode{dealias(type)} represents a class type +that is complete from some point in the evaluation context. \end{itemdescr} \indexlibraryglobal{enumerators_of}% @@ -5148,16 +5295,17 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\constantwhen -\tcode{dealias(type_enum)} represents an enumeration type, -and \tcode{is_enumerable_type(\brk{}type_enum)} is \tcode{true}. - \pnum \returns A \tcode{vector} containing the reflections of each enumerator of the enumeration represented by \tcode{dealias(type_enum)}, in the order in which they are declared. + +\pnum +\throws +\tcode{meta::exception} unless +\tcode{dealias(type_enum)} represents an enumeration type, +and \tcode{is_enumerable_type(\brk{}type_enum)} is \tcode{true}. \end{itemdescr} \rSec2[meta.reflection.layout]{Reflection layout queries} @@ -5187,14 +5335,6 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\constantwhen -\tcode{r} represents a non-static data member, -unnamed bit-field, or -direct base class relationship $(D, B)$ -for which either $B$ is not a virtual base class -or $D$ is not an abstract class. - \pnum Let $V$ be the offset in bits from the beginning of a complete object of the type represented by \tcode{parent_of(r)} @@ -5203,6 +5343,15 @@ \pnum \returns \tcode{\{$V$ / CHAR_BIT, V \% CHAR_BIT\}}. + +\pnum +\throws +\tcode{meta::exception} unless +\tcode{r} represents a non-static data member, +unnamed bit-field, or +direct base class relationship $(D, B)$ +for which either $B$ is not a virtual base class +or $D$ is not an abstract class. \end{itemdescr} \indexlibraryglobal{size_of}% @@ -5211,20 +5360,6 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\constantwhen -\tcode{dealias(r)} is a reflection of a -type, -object, -value, -variable of non-reference type, -non-static data member that is not a bit-field, -direct base class relationship, or -data member description $(T, N, A, W, \mathit{NUA})$\iref{class.mem.general} -where $W$ is not $\perp$. -If \tcode{dealias(r)} represents a type, -then \tcode{is_complete_type(r)} is \tcode{true}. - \pnum \returns If \tcode{r} represents @@ -5244,16 +5379,10 @@ If \tcode{b} represents a direct base class relationship of an empty base class, then \tcode{size_of(b) > 0} is \tcode{true}. \end{note} -\end{itemdescr} -\indexlibraryglobal{alignment_of}% -\begin{itemdecl} -consteval size_t alignment_of(info r); -\end{itemdecl} - -\begin{itemdescr} \pnum -\constantwhen +\throws +\tcode{meta::exception} unless \tcode{dealias(r)} is a reflection of a type, object, @@ -5261,10 +5390,18 @@ variable of non-reference type, non-static data member that is not a bit-field, direct base class relationship, or -data member description. +data member description $(T, N, A, W, \mathit{NUA})$\iref{class.mem.general} +where $W$ is not $\perp$. If \tcode{dealias(r)} represents a type, then \tcode{is_complete_type(r)} is \tcode{true}. +\end{itemdescr} + +\indexlibraryglobal{alignment_of}% +\begin{itemdecl} +consteval size_t alignment_of(info r); +\end{itemdecl} +\begin{itemdescr} \pnum \returns \begin{itemize} @@ -5290,28 +5427,28 @@ then the value of $A$. Otherwise, \tcode{alignment_of(\reflexpr{$T$})}. \end{itemize} -\end{itemdescr} -\indexlibraryglobal{bit_size_of}% -\begin{itemdecl} -consteval size_t bit_size_of(info r); -\end{itemdecl} - -\begin{itemdescr} \pnum -\constantwhen +\throws +\tcode{meta::exception} unless \tcode{dealias(r)} is a reflection of a type, object, value, variable of non-reference type, -non-static data member, -unnamed bit-field, +non-static data member that is not a bit-field, direct base class relationship, or data member description. -If \tcode{dealias(r)} represents a type $T$, -there is a point within the evaluation context from which $T$ is not incomplete. +If \tcode{dealias(r)} represents a type, +then \tcode{is_complete_type(r)} is \tcode{true}. +\end{itemdescr} + +\indexlibraryglobal{bit_size_of}% +\begin{itemdecl} +consteval size_t bit_size_of(info r); +\end{itemdecl} +\begin{itemdescr} \pnum \returns \begin{itemize} @@ -5329,6 +5466,21 @@ \item Otherwise, \tcode{CHAR_BIT * size_of(r)}. \end{itemize} + +\pnum +\throws +\tcode{meta::exception} unless +\tcode{dealias(r)} is a reflection of a +type, +object, +value, +variable of non-reference type, +non-static data member, +unnamed bit-field, +direct base class relationship, or +data member description. +If \tcode{dealias(r)} represents a type $T$, +there is a point within the evaluation context from which $T$ is not incomplete. \end{itemdescr} \rSec2[meta.reflection.extract]{Value extraction} @@ -5353,7 +5505,15 @@ \end{note} \pnum -\constantwhen +\returns +If \tcode{r} represents an object $O$, +then a reference ot $O$. +Otherwise, a reference to the object declared, or referred to, +by the variable represented by \tcode{r}. + +\pnum +\throws +\tcode{meta::exception} unless \begin{itemize} \item \tcode{r} represents a variable or object of type \tcode{U}, @@ -5368,13 +5528,6 @@ then either that variable is usable in constant expressions or its lifetime began within the core constant expression currently under evaluation. \end{itemize} - -\pnum -\returns -If \tcode{r} represents an object $O$, -then a reference ot $O$. -Otherwise, a reference to the object declared, or referred to, -by the variable represented by \tcode{r}. \end{itemdescr} \begin{itemdecl} @@ -5384,7 +5537,19 @@ \begin{itemdescr} \pnum -\constantwhen +\returns +\begin{itemize} +\item + If \tcode{T} is a pointer type, + then a pointer value pointing to the function represented by \tcode{r}. +\item + Otherwise, a pointer-to-member value + designating the non-static data member or function represented by \tcode{r}. +\end{itemize} + +\pnum +\throws +\tcode{meta::exception} unless \begin{itemize} \item \tcode{r} represents a non-static data member with type $X$, @@ -5404,17 +5569,6 @@ of function type \tcode{F} or \tcode{F noexcept}, and \tcode{T} is \tcode{F*}. \end{itemize} - -\pnum -\returns -\begin{itemize} -\item - If \tcode{T} is a pointer type, - then a pointer value pointing to the function represented by \tcode{r}. -\item - Otherwise, a pointer-to-member value - designating the non-static data member or function represented by \tcode{r}. -\end{itemize} \end{itemdescr} \begin{itemdecl} @@ -5427,7 +5581,14 @@ Let $U$ be the type of the value or object that \tcode{r} represents. \pnum -\constantwhen +\returns +\tcode{static_cast([:$R$:])}, +where $R$ is a constant expression of type \tcode{info} +such that \tcode{$R$ == r} is \tcode{true}. + +\pnum +\throws +\tcode{meta::exception} unless \begin{itemize} \item \tcode{U} is a pointer type, @@ -5445,12 +5606,6 @@ \tcode{T} is a function pointer type, and the value that \tcode{r} represents is convertible to \tcode{T}. \end{itemize} - -\pnum -\returns -\tcode{static_cast([:$R$:])}, -where $R$ is a constant expression of type \tcode{info} -such that \tcode{$R$ == r} is \tcode{true}. \end{itemdescr} \indexlibraryglobal{extract}% @@ -5491,12 +5646,6 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\constantwhen -\tcode{templ} represents a template, -and every reflection in \tcode{arguments} represents a construct -usable as a template argument\iref{temp.arg}. - \pnum Let \tcode{Z} be the template represented by \tcode{templ} and let \tcode{Args...} be a sequence of prvalue constant expressions @@ -5509,6 +5658,13 @@ whose type contains an undeduced placeholder type. Otherwise, \tcode{false}. +\pnum +\throws +\tcode{meta::exception} unless +\tcode{templ} represents a template, +and every reflection in \tcode{arguments} represents a construct +usable as a template argument\iref{temp.arg}. + \pnum \begin{note} If forming \tcode{Z<[:Args:]...>} leads to a failure @@ -5524,10 +5680,6 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\constantwhen -\tcode{can_substitute(templ, arguments)} is \tcode{true}. - \pnum Let \tcode{Z} be the template represented by \tcode{templ} and let \tcode{Args...} be a sequence of prvalue constant expressions @@ -5537,6 +5689,11 @@ \returns \tcode{\reflexpr{Z<[:Args:]...>}}. +\pnum +\throws +\tcode{meta::exception} unless +\tcode{can_substitute(templ, arguments)} is \tcode{true}. + \pnum \begin{note} If forming \tcode{Z<[:Args:]...>} leads to a failure outside of the immedaite context, @@ -5601,14 +5758,6 @@ otherwise, the value of \tcode{expr}. \end{itemize} -\pnum -\constantwhen -given the invented variable -\begin{codeblock} -template struct TCls; -\end{codeblock} -the \grammarterm{template-id} \tcode{TCls<$V$>} would be valid. - \pnum \returns \tcode{template_arguments_of(\reflexpr{TCls<$V$>})[0]}. @@ -5637,6 +5786,15 @@ // points to string literal \end{codeblock} \end{example} + +\pnum +\throws +\tcode{meta::exception} unless +the \grammarterm{template-id} \tcode{TCls<$V$>} would be valid +given the invented variable +\begin{codeblock} +template struct TCls; +\end{codeblock} \end{itemdescr} \indexlibraryglobal{reflect_object}% @@ -5650,14 +5808,15 @@ \mandates \tcode{T} is an object type. -\pnum -\constantwhen -\tcode{expr} is suitable for use as a constant template argument -for a constant template parameter of type \tcode{T\&}\iref{temp.arg.nontype}. - \pnum \returns A reflection of the object designated by \tcode{expr}. + +\pnum +\throws +\tcode{meta::exception} unless +\tcode{expr} is suitable for use as a constant template argument +for a constant template parameter of type \tcode{T\&}\iref{temp.arg.nontype}. \end{itemdescr} \indexlibraryglobal{reflect_function}% @@ -5671,14 +5830,15 @@ \mandates \tcode{T} is a function type. -\pnum -\constantwhen -\tcode{expr} is suitable for use as a constant template argument -for a constant template parameter of type \tcode{T\&}\iref{temp.arg.nontype}. - \pnum \returns A reflection of the function designated by \tcode{fn}. + +\pnum +\throws +\tcode{meta::exception} unless +\tcode{expr} is suitable for use as a constant template argument +for a constant template parameter of type \tcode{T\&}\iref{temp.arg.nontype}. \end{itemdescr} \rSec2[meta.reflection.array]{Promoting to static storage arrays} @@ -5742,11 +5902,6 @@ \tcode{is_constructible_v>} is \tcode{true}, and \tcode{is_copy_constructible_v} is \tcode{true}. -\pnum -\constantwhen -\tcode{reflect_constant(e)} is a constant subexpression -for every element \tcode{e} of \tcode{r}. - \pnum Let $V$ be the pack of values of type \tcode{info} of the same size as \tcode{r}, @@ -5771,6 +5926,12 @@ \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}. @@ -5858,7 +6019,34 @@ \begin{itemdescr} \pnum -\constantwhen +\returns +A reflection of a data member description +$(T, N, A, W, \mathit{NUA})$\iref{class.mem.general} where +\begin{itemize} +\item + $T$ is the type represented by \tcode{dealias(type)}, +\item + $N$ is either the identifier encoded by \tcode{options.name} + or $\perp$ if \tcode{options.name} does not contain a value, +\item + $A$ is either the alignment value held by \tcode{options.alignment} + or $\perp$ if \tcode{options.alignment} does not contain a value, +\item + $W$ is either the value held by \tcode{options.bit_width} + or $\perp$ if \tcode{options.bit_width} does not contain a value, and +\item + $\mathit{NUA}$ is the value held by \tcode{options.no_unique_address}. +\end{itemize} +\begin{note} +The returned reflection value is primarily useful +in conjunction with \tcode{define_aggregate}; +it can also be queried by certain other functions in \tcode{std::meta} +(e.g., \tcode{type_of}, \tcode{identifier_of}). +\end{note} + +\pnum +\throws +\tcode{meta::exception} unless the following conditions are met: \begin{itemize} \item \tcode{dealias(type)} represents eitehr an object type or a reference type; @@ -5908,32 +6096,6 @@ it is an alignment value\iref{basic.align} not less than \tcode{alignment_of(type)}. \end{itemize} - -\pnum -\returns -A reflection of a data member description -$(T, N, A, W, \mathit{NUA})$\iref{class.mem.general} where -\begin{itemize} -\item - $T$ is the type represented by \tcode{dealias(type)}, -\item - $N$ is either the identifier encoded by \tcode{options.name} - or $\perp$ if \tcode{options.name} does not contain a value, -\item - $A$ is either the alignment value held by \tcode{options.alignment} - or $\perp$ if \tcode{options.alignment} does not contain a value, -\item - $W$ is either the value held by \tcode{options.bit_width} - or $\perp$ if \tcode{options.bit_width} does not contain a value, and -\item - $\mathit{NUA}$ is the value held by \tcode{options.no_unique_address}. -\end{itemize} -\begin{note} -The returned reflection value is primarily useful -in conjunction with \tcode{define_aggregate}; -it can also be queried by certain other functions in \tcode{std::meta} -(e.g., \tcode{type_of}, \tcode{identifier_of}). -\end{note} \end{itemdescr} \indexlibraryglobal{is_data_member_spec}% @@ -6416,19 +6578,6 @@ \begin{itemdescr} \pnum -\constantwhen -\tcode{item} represents a -type, -type alias, -variable, -function, -namespace, -enumerator, -direct base class relationship, or -non-static data member. - -%FIXME: it is highly unusual for this subclause to put Let paragraphs after Constant When -\pnum Let $E$ be \begin{itemize} \item @@ -6488,6 +6637,19 @@ static_assert(annotations_of(^^x)[0] == annotations_of(^^y)[0]); \end{codeblock} \end{example} + +\pnum +\throws +\tcode{meta::exception} unless +\tcode{item} represents a +type, +type alias, +variable, +function, +namespace, +enumerator, +direct base class relationship, or +non-static data member. \end{itemdescr} \indexlibraryglobal{annotations_of_with_type}% @@ -6496,16 +6658,6 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\constantwhen -\begin{itemize} -\item - \tcode{annotations_of(item)} is a constant expression and -\item - \tcode{dealias(type)} represents a type that is complete - from some point in the evaluation context. -\end{itemize} - \pnum \returns A \tcode{vector} containing each element \tcode{e} of \tcode{annotations_of(item)} @@ -6514,6 +6666,17 @@ remove_const(type_of(e)) == remove_const(type) \end{codeblock} is \tcode{true}, preserving their order. + +\pnum +\throws +\tcode{meta::exception} unless +\begin{itemize} +\item + \tcode{annotations_of(item)} is a constant expression and +\item + \tcode{dealias(type)} represents a type that is complete + from some point in the evaluation context. +\end{itemize} \end{itemdescr} \rSec1[ratio]{Compile-time rational arithmetic}