|
2665 | 2665 | consteval bool is_move_assignment(info r);
|
2666 | 2666 | consteval bool is_destructor(info r);
|
2667 | 2667 |
|
| 2668 | + consteval bool is_function_parameter(info r); |
| 2669 | + consteval bool is_explicit_object_parameter(info r); |
| 2670 | + consteval bool has_default_argument(info r); |
| 2671 | + consteval bool has_ellipsis_parameter(info r); |
| 2672 | + |
2668 | 2673 | consteval bool is_template(info r);
|
2669 | 2674 | consteval bool is_function_template(info r);
|
2670 | 2675 | consteval bool is_variable_template(info r);
|
|
2697 | 2702 | consteval bool has_template_arguments(info r);
|
2698 | 2703 | consteval info template_of(info r);
|
2699 | 2704 | consteval vector<info> template_arguments_of(info r);
|
| 2705 | + consteval vector<info> parameters_of(info r); |
| 2706 | + consteval info variable_of(info r); |
| 2707 | + consteval info return_type_of(info r); |
2700 | 2708 |
|
2701 | 2709 | // \ref{meta.reflection.access.context}, access control context
|
2702 | 2710 | struct access_context;
|
|
3111 | 3119 | operator function template,
|
3112 | 3120 | or conversion function template.
|
3113 | 3121 | Otherwise, \tcode{false}.
|
| 3122 | +\item |
| 3123 | + Otherwise, if \tcode{r} represents the $i^\text{th}$ parameter |
| 3124 | + of a function $F$, |
| 3125 | + then let $S$ be the set of declarations, |
| 3126 | + ignoring any explicit instantiations, |
| 3127 | + that precede some point in the evaluation context |
| 3128 | + and that declare either $F$ or a templated function |
| 3129 | + of which $F$ is a specialization; |
| 3130 | + \tcode{true} if |
| 3131 | + \begin{itemize} |
| 3132 | + \item |
| 3133 | + there is a declaration $D$ in $S$ that introduces a name $N$ for either $P$ |
| 3134 | + or the parameter corresponding to $P$ |
| 3135 | + in the templated function that $D$ declares and |
| 3136 | + \item |
| 3137 | + no declaration in $S$ does so using any name other than $N$. |
| 3138 | + \end{itemize} |
| 3139 | + Otherwise, \tcode{false}. |
| 3140 | + \begin{example} |
| 3141 | +\begin{codeblock} |
| 3142 | +void fun(int); |
| 3143 | +constexpr std::meta::info r = parameters_of(^^fun)[0]; |
| 3144 | +static_assert(!has_identifier(r)); |
| 3145 | + |
| 3146 | +void fun(int x); |
| 3147 | +static_assert(has_identifier(r)); |
| 3148 | + |
| 3149 | +void fun(int x); |
| 3150 | +static_assert(has_identifier(r)); |
| 3151 | + |
| 3152 | +void poison() { |
| 3153 | + void fun(int y); |
| 3154 | +} |
| 3155 | +static_assert(!has_identifier(r)); |
| 3156 | +\end{codeblock} |
| 3157 | + \end{example} |
3114 | 3158 | \item
|
3115 | 3159 | Otherwise, if \tcode{r} represents a variable,
|
3116 | 3160 | then \tcode{false} if the declaration of that variable
|
|
3171 | 3215 | \item
|
3172 | 3216 | Otherwise, if \tcode{r} represents a literal operator or literal operator template,
|
3173 | 3217 | then the \grammarterm{ud-suffix} of the operator or operator template.
|
| 3218 | +\item |
| 3219 | + Otherwise, if \tcode{r} represents the parameter $P$ of a function $F$, |
| 3220 | + then let $S$ be the set of declarations, |
| 3221 | + ignoring any explicit instantiations, |
| 3222 | + that precede some point in the evaluation context |
| 3223 | + and that declare either $F$ |
| 3224 | + or a templated function of which $F$ is a specialization; |
| 3225 | + the name that was introduced by a declaration in $S$ |
| 3226 | + for the parameter corresponding to $P$. |
3174 | 3227 | \item
|
3175 | 3228 | Otherwise, if \tcode{r} represents an entity,
|
3176 | 3229 | then the identifier introduced by the declaration of that entity.
|
|
3269 | 3322 | \returns
|
3270 | 3323 | \begin{itemize}
|
3271 | 3324 | \item
|
3272 |
| - If \tcode{r} represents a |
| 3325 | + If \tcode{r} represents the $i^\text{th}$ parameter of a function $F$, |
| 3326 | + then the $i^\text{th}$ type |
| 3327 | + in the parameter-type-list of $F$\iref{dcl.fct}. |
| 3328 | +\item |
| 3329 | + Otherwise, if \tcode{r} represents a |
3273 | 3330 | value,
|
3274 | 3331 | object,
|
3275 | 3332 | variable,
|
|
3828 | 3885 | Otherwise, \tcode{false}.
|
3829 | 3886 | \end{itemdescr}
|
3830 | 3887 |
|
| 3888 | +\indexlibraryglobal{is_function_parameter}% |
| 3889 | +\begin{itemdecl} |
| 3890 | +consteval bool is_function_parameter(info r); |
| 3891 | +\end{itemdecl} |
| 3892 | + |
| 3893 | +\begin{itemdescr} |
| 3894 | +\pnum |
| 3895 | +\returns |
| 3896 | +\tcode{true} if \tcode{r} represents a function parameter. |
| 3897 | +Otherwise, \tcode{false}. |
| 3898 | +\end{itemdescr} |
| 3899 | + |
| 3900 | +\indexlibraryglobal{is_explicit_object_parameter}% |
| 3901 | +\begin{itemdecl} |
| 3902 | +consteval bool is_explicit_object_parameter(info r); |
| 3903 | +\end{itemdecl} |
| 3904 | + |
| 3905 | +\begin{itemdescr} |
| 3906 | +\pnum |
| 3907 | +\returns |
| 3908 | +\tcode{true} if \tcode{r} represents a function parameter |
| 3909 | +that is an explicit object parameter\iref{dcl.fct}. |
| 3910 | +Otherwise, \tcode{false}. |
| 3911 | +\end{itemdescr} |
| 3912 | + |
| 3913 | +\indexlibraryglobal{has_default_argument}% |
| 3914 | +\begin{itemdecl} |
| 3915 | +consteval bool has_default_argument(info r); |
| 3916 | +\end{itemdecl} |
| 3917 | + |
| 3918 | +\begin{itemdescr} |
| 3919 | +\pnum |
| 3920 | +\returns |
| 3921 | +If \tcode{r} represenst a parameter $P$ of a function $F$, then: |
| 3922 | +\begin{itemize} |
| 3923 | +\item |
| 3924 | + If $F$ is a specialization of a templated function $T$, |
| 3925 | + then \tcode{true} if there exists a declaration $D$ of $T$ |
| 3926 | + that precedes some point in the evaluation context |
| 3927 | + and $D$ specifies a default argument |
| 3928 | + for the parameter of $T$ corresponding to $P$. |
| 3929 | + Otherwise, \tcode{false}. |
| 3930 | +\item |
| 3931 | + Otherwise, if there exists a declaration $D$ of $F$ |
| 3932 | + that precedes some point in the evaluation context |
| 3933 | + and $D$ specifies a default argument for $P$, |
| 3934 | + then \tcode{true}. |
| 3935 | +\end{itemize} |
| 3936 | +Otherwise, \tcode{false}. |
| 3937 | +\end{itemdescr} |
| 3938 | + |
| 3939 | +\indexlibraryglobal{has_ellipsis_parameter}% |
| 3940 | +\begin{itemdecl} |
| 3941 | +consteval bool has_ellipsis_parameter(info r); |
| 3942 | +\end{itemdecl} |
| 3943 | + |
| 3944 | +\begin{itemdescr} |
| 3945 | +\pnum |
| 3946 | +\returns |
| 3947 | +\tcode{true} if \tcode{r} represents a function type |
| 3948 | +that has an ellipsis in its parameter-type-list\iref{dcl.fct}. |
| 3949 | +Otherwise, \tcode{false}. |
| 3950 | +\end{itemdescr} |
| 3951 | + |
3831 | 3952 | \indexlibraryglobal{is_template}%
|
3832 | 3953 | \begin{itemdecl}
|
3833 | 3954 | consteval bool is_template(info r);
|
|
4185 | 4306 | \end{example}
|
4186 | 4307 | \end{itemdescr}
|
4187 | 4308 |
|
| 4309 | +\indexlibraryglobal{parameters_of}% |
| 4310 | +\begin{itemdecl} |
| 4311 | +consteval vector<info> parameters_of(info r); |
| 4312 | +\end{itemdecl} |
| 4313 | + |
| 4314 | +\begin{itemdescr} |
| 4315 | +\pnum |
| 4316 | +\constantwhen |
| 4317 | +\tcode{r} represents a function or a function type. |
| 4318 | + |
| 4319 | +\pnum |
| 4320 | +\returns |
| 4321 | +\begin{itemize} |
| 4322 | +\item |
| 4323 | + If \tcode{r} represents a function $F$, |
| 4324 | + then a \tcode{vector} containing reflections of the parameters of $F$, |
| 4325 | + in the order they appear in a declaration of $F$. |
| 4326 | +\item |
| 4327 | + Otherwise, \tcode{r} represents a function type $T$; |
| 4328 | + a \tcode{vector} containing reflections of the types |
| 4329 | + in parameter-type-list\iref{dcl.fct} of $T$, |
| 4330 | + in the order they appear in the parameter-type-list. |
| 4331 | +\end{itemize} |
| 4332 | +\end{itemdescr} |
| 4333 | + |
| 4334 | +\indexlibraryglobal{variable_of}% |
| 4335 | +\begin{itemdecl} |
| 4336 | +consteval info variable_of(info r); |
| 4337 | +\end{itemdecl} |
| 4338 | + |
| 4339 | +\begin{itemdescr} |
| 4340 | +\pnum |
| 4341 | +\constantwhen |
| 4342 | +\begin{itemize} |
| 4343 | +\item |
| 4344 | + \tcode{r} represents a parameter of a function $F$ and |
| 4345 | +\item |
| 4346 | + there is a point $P$ in the evaluation context |
| 4347 | + for which the innermost non-block scope enclosing $P$ |
| 4348 | + is the function parameter scope\iref{basic.scope.param} |
| 4349 | + associated with $F$. |
| 4350 | +\end{itemize} |
| 4351 | + |
| 4352 | +\pnum |
| 4353 | +\returns |
| 4354 | +The reflection of the parameter variable corresponding to \tcode{r}. |
| 4355 | +\end{itemdescr} |
| 4356 | + |
| 4357 | +\indexlibraryglobal{return_type_of}% |
| 4358 | +\begin{itemdecl} |
| 4359 | +consteval info return_type_of(info r); |
| 4360 | +\end{itemdecl} |
| 4361 | + |
| 4362 | +\begin{itemdescr} |
| 4363 | +\pnum |
| 4364 | +\constantwhen |
| 4365 | +Either \tcode{r} represents a function |
| 4366 | +and \tcode{\exposid{has-type}(r)} is \tcode{true} |
| 4367 | +or \tcode{r} represents a function type. |
| 4368 | + |
| 4369 | +\pnum |
| 4370 | +\returns |
| 4371 | +The reflection of the return type |
| 4372 | +of the function or function type represented by \tcode{r}. |
| 4373 | +\end{itemdescr} |
| 4374 | + |
4188 | 4375 | \rSec2[meta.reflection.access.context]{Access control context}
|
4189 | 4376 |
|
4190 | 4377 | \pnum
|
|
0 commit comments