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