|
2683 | 2683 | consteval bool is_move_assignment(info r);
|
2684 | 2684 | consteval bool is_destructor(info r);
|
2685 | 2685 |
|
| 2686 | + consteval bool is_function_parameter(info r); |
| 2687 | + consteval bool is_explicit_object_parameter(info r); |
| 2688 | + consteval bool has_default_argument(info r); |
| 2689 | + consteval bool has_ellipsis_parameter(info r); |
| 2690 | + |
2686 | 2691 | consteval bool is_template(info r);
|
2687 | 2692 | consteval bool is_function_template(info r);
|
2688 | 2693 | consteval bool is_variable_template(info r);
|
|
2715 | 2720 | consteval bool has_template_arguments(info r);
|
2716 | 2721 | consteval info template_of(info r);
|
2717 | 2722 | consteval vector<info> template_arguments_of(info r);
|
| 2723 | + consteval vector<info> parameters_of(info r); |
| 2724 | + consteval info variable_of(info r); |
| 2725 | + consteval info return_type_of(info r); |
2718 | 2726 |
|
2719 | 2727 | // \ref{meta.reflection.access.context}, access control context
|
2720 | 2728 | struct access_context;
|
|
3238 | 3246 | operator function template,
|
3239 | 3247 | or conversion function template.
|
3240 | 3248 | Otherwise, \tcode{false}.
|
| 3249 | +\item |
| 3250 | + Otherwise, if \tcode{r} represents the $i^\text{th}$ parameter |
| 3251 | + of a function $F$, |
| 3252 | + then let $S$ be the set of declarations, |
| 3253 | + ignoring any explicit instantiations, |
| 3254 | + that precede some point in the evaluation context |
| 3255 | + and that declare either $F$ or a templated function |
| 3256 | + of which $F$ is a specialization; |
| 3257 | + \tcode{true} if |
| 3258 | + \begin{itemize} |
| 3259 | + \item |
| 3260 | + there is a declaration $D$ in $S$ that introduces a name $N$ for either $P$ |
| 3261 | + or the parameter corresponding to $P$ |
| 3262 | + in the templated function that $D$ declares and |
| 3263 | + \item |
| 3264 | + no declaration in $S$ does so using any name other than $N$. |
| 3265 | + \end{itemize} |
| 3266 | + Otherwise, \tcode{false}. |
| 3267 | + \begin{example} |
| 3268 | +\begin{codeblock} |
| 3269 | +void fun(int); |
| 3270 | +constexpr std::meta::info r = parameters_of(^^fun)[0]; |
| 3271 | +static_assert(!has_identifier(r)); |
| 3272 | + |
| 3273 | +void fun(int x); |
| 3274 | +static_assert(has_identifier(r)); |
| 3275 | + |
| 3276 | +void fun(int x); |
| 3277 | +static_assert(has_identifier(r)); |
| 3278 | + |
| 3279 | +void poison() { |
| 3280 | + void fun(int y); |
| 3281 | +} |
| 3282 | +static_assert(!has_identifier(r)); |
| 3283 | +\end{codeblock} |
| 3284 | + \end{example} |
3241 | 3285 | \item
|
3242 | 3286 | Otherwise, if \tcode{r} represents a variable,
|
3243 | 3287 | then \tcode{false} if the declaration of that variable
|
|
3298 | 3342 | \item
|
3299 | 3343 | Otherwise, if \tcode{r} represents a literal operator or literal operator template,
|
3300 | 3344 | then the \grammarterm{ud-suffix} of the operator or operator template.
|
| 3345 | +\item |
| 3346 | + Otherwise, if \tcode{r} represents the parameter $P$ of a function $F$, |
| 3347 | + then let $S$ be the set of declarations, |
| 3348 | + ignoring any explicit instantiations, |
| 3349 | + that precede some point in the evaluation context |
| 3350 | + and that declare either $F$ |
| 3351 | + or a templated function of which $F$ is a specialization; |
| 3352 | + the name that was introduced by a declaration in $S$ |
| 3353 | + for the parameter corresponding to $P$. |
3301 | 3354 | \item
|
3302 | 3355 | Otherwise, if \tcode{r} represents an entity,
|
3303 | 3356 | then the identifier introduced by the declaration of that entity.
|
|
3397 | 3450 | \returns
|
3398 | 3451 | \begin{itemize}
|
3399 | 3452 | \item
|
3400 |
| - If \tcode{r} represents a |
| 3453 | + If \tcode{r} represents the $i^\text{th}$ parameter of a function $F$, |
| 3454 | + then the $i^\text{th}$ type |
| 3455 | + in the parameter-type-list of $F$\iref{dcl.fct}. |
| 3456 | +\item |
| 3457 | + Otherwise, if \tcode{r} represents a |
3401 | 3458 | value,
|
3402 | 3459 | object,
|
3403 | 3460 | variable,
|
|
3968 | 4025 | Otherwise, \tcode{false}.
|
3969 | 4026 | \end{itemdescr}
|
3970 | 4027 |
|
| 4028 | +\indexlibraryglobal{is_function_parameter}% |
| 4029 | +\begin{itemdecl} |
| 4030 | +consteval bool is_function_parameter(info r); |
| 4031 | +\end{itemdecl} |
| 4032 | + |
| 4033 | +\begin{itemdescr} |
| 4034 | +\pnum |
| 4035 | +\returns |
| 4036 | +\tcode{true} if \tcode{r} represents a function parameter. |
| 4037 | +Otherwise, \tcode{false}. |
| 4038 | +\end{itemdescr} |
| 4039 | + |
| 4040 | +\indexlibraryglobal{is_explicit_object_parameter}% |
| 4041 | +\begin{itemdecl} |
| 4042 | +consteval bool is_explicit_object_parameter(info r); |
| 4043 | +\end{itemdecl} |
| 4044 | + |
| 4045 | +\begin{itemdescr} |
| 4046 | +\pnum |
| 4047 | +\returns |
| 4048 | +\tcode{true} if \tcode{r} represents a function parameter |
| 4049 | +that is an explicit object parameter\iref{dcl.fct}. |
| 4050 | +Otherwise, \tcode{false}. |
| 4051 | +\end{itemdescr} |
| 4052 | + |
| 4053 | +\indexlibraryglobal{has_default_argument}% |
| 4054 | +\begin{itemdecl} |
| 4055 | +consteval bool has_default_argument(info r); |
| 4056 | +\end{itemdecl} |
| 4057 | + |
| 4058 | +\begin{itemdescr} |
| 4059 | +\pnum |
| 4060 | +\returns |
| 4061 | +If \tcode{r} represenst a parameter $P$ of a function $F$, then: |
| 4062 | +\begin{itemize} |
| 4063 | +\item |
| 4064 | + If $F$ is a specialization of a templated function $T$, |
| 4065 | + then \tcode{true} if there exists a declaration $D$ of $T$ |
| 4066 | + that precedes some point in the evaluation context |
| 4067 | + and $D$ specifies a default argument |
| 4068 | + for the parameter of $T$ corresponding to $P$. |
| 4069 | + Otherwise, \tcode{false}. |
| 4070 | +\item |
| 4071 | + Otherwise, if there exists a declaration $D$ of $F$ |
| 4072 | + that precedes some point in the evaluation context |
| 4073 | + and $D$ specifies a default argument for $P$, |
| 4074 | + then \tcode{true}. |
| 4075 | +\end{itemize} |
| 4076 | +Otherwise, \tcode{false}. |
| 4077 | +\end{itemdescr} |
| 4078 | + |
| 4079 | +\indexlibraryglobal{has_ellipsis_parameter}% |
| 4080 | +\begin{itemdecl} |
| 4081 | +consteval bool has_ellipsis_parameter(info r); |
| 4082 | +\end{itemdecl} |
| 4083 | + |
| 4084 | +\begin{itemdescr} |
| 4085 | +\pnum |
| 4086 | +\returns |
| 4087 | +\tcode{true} if \tcode{r} represents a function type |
| 4088 | +that has an ellipsis in its parameter-type-list\iref{dcl.fct}. |
| 4089 | +Otherwise, \tcode{false}. |
| 4090 | +\end{itemdescr} |
| 4091 | + |
3971 | 4092 | \indexlibraryglobal{is_template}%
|
3972 | 4093 | \begin{itemdecl}
|
3973 | 4094 | consteval bool is_template(info r);
|
|
4325 | 4446 | \end{example}
|
4326 | 4447 | \end{itemdescr}
|
4327 | 4448 |
|
| 4449 | +\indexlibraryglobal{parameters_of}% |
| 4450 | +\begin{itemdecl} |
| 4451 | +consteval vector<info> parameters_of(info r); |
| 4452 | +\end{itemdecl} |
| 4453 | + |
| 4454 | +\begin{itemdescr} |
| 4455 | +\pnum |
| 4456 | +\constantwhen |
| 4457 | +\tcode{r} represents a function or a function type. |
| 4458 | + |
| 4459 | +\pnum |
| 4460 | +\returns |
| 4461 | +\begin{itemize} |
| 4462 | +\item |
| 4463 | + If \tcode{r} represents a function $F$, |
| 4464 | + then a \tcode{vector} containing reflections of the parameters of $F$, |
| 4465 | + in the order they appear in a declaration of $F$. |
| 4466 | +\item |
| 4467 | + Otherwise, \tcode{r} represents a function type $T$; |
| 4468 | + a \tcode{vector} containing reflections of the types |
| 4469 | + in parameter-type-list\iref{dcl.fct} of $T$, |
| 4470 | + in the order they appear in the parameter-type-list. |
| 4471 | +\end{itemize} |
| 4472 | +\end{itemdescr} |
| 4473 | + |
| 4474 | +\indexlibraryglobal{variable_of}% |
| 4475 | +\begin{itemdecl} |
| 4476 | +consteval info variable_of(info r); |
| 4477 | +\end{itemdecl} |
| 4478 | + |
| 4479 | +\begin{itemdescr} |
| 4480 | +\pnum |
| 4481 | +\constantwhen |
| 4482 | +\begin{itemize} |
| 4483 | +\item |
| 4484 | + \tcode{r} represents a parameter of a function $F$ and |
| 4485 | +\item |
| 4486 | + there is a point $P$ in the evaluation context |
| 4487 | + for which the innermost non-block scope enclosing $P$ |
| 4488 | + is the function parameter scope\iref{basic.scope.param} |
| 4489 | + associated with $F$. |
| 4490 | +\end{itemize} |
| 4491 | + |
| 4492 | +\pnum |
| 4493 | +\returns |
| 4494 | +The reflection of the parameter variable corresponding to \tcode{r}. |
| 4495 | +\end{itemdescr} |
| 4496 | + |
| 4497 | +\indexlibraryglobal{return_type_of}% |
| 4498 | +\begin{itemdecl} |
| 4499 | +consteval info return_type_of(info r); |
| 4500 | +\end{itemdecl} |
| 4501 | + |
| 4502 | +\begin{itemdescr} |
| 4503 | +\pnum |
| 4504 | +\constantwhen |
| 4505 | +Either \tcode{r} represents a function |
| 4506 | +and \tcode{\exposid{has-type}(r)} is \tcode{true} |
| 4507 | +or \tcode{r} represents a function type. |
| 4508 | + |
| 4509 | +\pnum |
| 4510 | +\returns |
| 4511 | +The reflection of the return type |
| 4512 | +of the function or function type represented by \tcode{r}. |
| 4513 | +\end{itemdescr} |
| 4514 | + |
4328 | 4515 | \rSec2[meta.reflection.access.context]{Access control context}
|
4329 | 4516 |
|
4330 | 4517 | \pnum
|
|
0 commit comments