|
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 of a function $F$ |
| 3251 | + that is an (implicit or explicit) specialization of a templated function $T$ |
| 3252 | + and the $i^\text{th}$ parameter of the instantiated declaration of $T$ |
| 3253 | + whose template arguments are those of $F$ would be instantiated from a pack, |
| 3254 | + then \tcode{false}. |
| 3255 | +\item |
| 3256 | + Otherwise, if \tcode{r} represents the parameter $P$ of a function $F$, |
| 3257 | + then let $S$ be the set of declarations, |
| 3258 | + ignoring any explicit instantiations, |
| 3259 | + that precede some point in the evaluation context |
| 3260 | + and that declare either $F$ or a templated function |
| 3261 | + of which $F$ is a specialization; |
| 3262 | + \tcode{true} if |
| 3263 | + \begin{itemize} |
| 3264 | + \item |
| 3265 | + there is a declaration $D$ in $S$ that introduces a name $N$ for either $P$ |
| 3266 | + or the parameter corresponding to $P$ |
| 3267 | + in the templated function that $D$ declares and |
| 3268 | + \item |
| 3269 | + no declaration in $S$ does so using any name other than $N$. |
| 3270 | + \end{itemize} |
| 3271 | + Otherwise, \tcode{false}. |
| 3272 | + \begin{example} |
| 3273 | +\begin{codeblock} |
| 3274 | +void fun(int); |
| 3275 | +constexpr std::meta::info r = parameters_of(^^fun)[0]; |
| 3276 | +static_assert(!has_identifier(r)); |
| 3277 | + |
| 3278 | +void fun(int x); |
| 3279 | +static_assert(has_identifier(r)); |
| 3280 | + |
| 3281 | +void fun(int x); |
| 3282 | +static_assert(has_identifier(r)); |
| 3283 | + |
| 3284 | +void poison() { |
| 3285 | + void fun(int y); |
| 3286 | +} |
| 3287 | +static_assert(!has_identifier(r)); |
| 3288 | +\end{codeblock} |
| 3289 | + \end{example} |
3241 | 3290 | \item
|
3242 | 3291 | Otherwise, if \tcode{r} represents a variable,
|
3243 | 3292 | then \tcode{false} if the declaration of that variable
|
|
3298 | 3347 | \item
|
3299 | 3348 | Otherwise, if \tcode{r} represents a literal operator or literal operator template,
|
3300 | 3349 | then the \grammarterm{ud-suffix} of the operator or operator template.
|
| 3350 | +\item |
| 3351 | + Otherwise, if \tcode{r} represents the parameter $P$ of a function $F$, |
| 3352 | + then let $S$ be the set of declarations, |
| 3353 | + ignoring any explicit instantiations, |
| 3354 | + that precede some point in the evaluation context |
| 3355 | + and that declare either $F$ |
| 3356 | + or a templated function of which $F$ is a specialization; |
| 3357 | + the name that was introduced by a declaration in $S$ |
| 3358 | + for the parameter corresponding to $P$. |
3301 | 3359 | \item
|
3302 | 3360 | Otherwise, if \tcode{r} represents an entity,
|
3303 | 3361 | then the identifier introduced by the declaration of that entity.
|
|
3378 | 3436 | enumerator,
|
3379 | 3437 | non-static data member,
|
3380 | 3438 | unnamed bit-field,
|
3381 |
| -direct base class relationship, or |
3382 |
| -data member description. |
| 3439 | +direct base class relationship, |
| 3440 | +data member description, or |
| 3441 | +function parameter. |
3383 | 3442 | Otherwise, \tcode{false}.
|
3384 | 3443 | \end{itemdescr}
|
3385 | 3444 |
|
|
3397 | 3456 | \returns
|
3398 | 3457 | \begin{itemize}
|
3399 | 3458 | \item
|
3400 |
| - If \tcode{r} represents a |
| 3459 | + If \tcode{r} represents the $i^\text{th}$ parameter of a function $F$, |
| 3460 | + then the $i^\text{th}$ type |
| 3461 | + in the parameter-type-list of $F$\iref{dcl.fct}. |
| 3462 | +\item |
| 3463 | + Otherwise, if \tcode{r} represents a |
3401 | 3464 | value,
|
3402 | 3465 | object,
|
3403 | 3466 | variable,
|
|
3968 | 4031 | Otherwise, \tcode{false}.
|
3969 | 4032 | \end{itemdescr}
|
3970 | 4033 |
|
| 4034 | +\indexlibraryglobal{is_function_parameter}% |
| 4035 | +\begin{itemdecl} |
| 4036 | +consteval bool is_function_parameter(info r); |
| 4037 | +\end{itemdecl} |
| 4038 | + |
| 4039 | +\begin{itemdescr} |
| 4040 | +\pnum |
| 4041 | +\returns |
| 4042 | +\tcode{true} if \tcode{r} represents a function parameter. |
| 4043 | +Otherwise, \tcode{false}. |
| 4044 | +\end{itemdescr} |
| 4045 | + |
| 4046 | +\indexlibraryglobal{is_explicit_object_parameter}% |
| 4047 | +\begin{itemdecl} |
| 4048 | +consteval bool is_explicit_object_parameter(info r); |
| 4049 | +\end{itemdecl} |
| 4050 | + |
| 4051 | +\begin{itemdescr} |
| 4052 | +\pnum |
| 4053 | +\returns |
| 4054 | +\tcode{true} if \tcode{r} represents a function parameter |
| 4055 | +that is an explicit object parameter\iref{dcl.fct}. |
| 4056 | +Otherwise, \tcode{false}. |
| 4057 | +\end{itemdescr} |
| 4058 | + |
| 4059 | +\indexlibraryglobal{has_default_argument}% |
| 4060 | +\begin{itemdecl} |
| 4061 | +consteval bool has_default_argument(info r); |
| 4062 | +\end{itemdecl} |
| 4063 | + |
| 4064 | +\begin{itemdescr} |
| 4065 | +\pnum |
| 4066 | +\returns |
| 4067 | +If \tcode{r} represenst a parameter $P$ of a function $F$, then: |
| 4068 | +\begin{itemize} |
| 4069 | +\item |
| 4070 | + If $F$ is a specialization of a templated function $T$, |
| 4071 | + then \tcode{true} if there exists a declaration $D$ of $T$ |
| 4072 | + that precedes some point in the evaluation context |
| 4073 | + and $D$ specifies a default argument |
| 4074 | + for the parameter of $T$ corresponding to $P$. |
| 4075 | + Otherwise, \tcode{false}. |
| 4076 | +\item |
| 4077 | + Otherwise, if there exists a declaration $D$ of $F$ |
| 4078 | + that precedes some point in the evaluation context |
| 4079 | + and $D$ specifies a default argument for $P$, |
| 4080 | + then \tcode{true}. |
| 4081 | +\end{itemize} |
| 4082 | +Otherwise, \tcode{false}. |
| 4083 | +\end{itemdescr} |
| 4084 | + |
| 4085 | +\indexlibraryglobal{has_ellipsis_parameter}% |
| 4086 | +\begin{itemdecl} |
| 4087 | +consteval bool has_ellipsis_parameter(info r); |
| 4088 | +\end{itemdecl} |
| 4089 | + |
| 4090 | +\begin{itemdescr} |
| 4091 | +\pnum |
| 4092 | +\returns |
| 4093 | +\tcode{true} if \tcode{r} represents a function type |
| 4094 | +that has an ellipsis in its parameter-type-list\iref{dcl.fct}. |
| 4095 | +Otherwise, \tcode{false}. |
| 4096 | +\end{itemdescr} |
| 4097 | + |
3971 | 4098 | \indexlibraryglobal{is_template}%
|
3972 | 4099 | \begin{itemdecl}
|
3973 | 4100 | consteval bool is_template(info r);
|
|
4266 | 4393 | A \tcode{vector} containing reflections
|
4267 | 4394 | of the template arguments
|
4268 | 4395 | of the template specialization represented by \tcode{r},
|
4269 |
| -in the order they appear in the corresponding template argument list. |
| 4396 | +in the order in which they appear in the corresponding template argument list. |
4270 | 4397 | For a given template argument $A$,
|
4271 | 4398 | its corresponding reflection $R$ is determined as follows:
|
4272 | 4399 | \begin{itemize}
|
|
4325 | 4452 | \end{example}
|
4326 | 4453 | \end{itemdescr}
|
4327 | 4454 |
|
| 4455 | +\indexlibraryglobal{parameters_of}% |
| 4456 | +\begin{itemdecl} |
| 4457 | +consteval vector<info> parameters_of(info r); |
| 4458 | +\end{itemdecl} |
| 4459 | + |
| 4460 | +\begin{itemdescr} |
| 4461 | +\pnum |
| 4462 | +\constantwhen |
| 4463 | +\tcode{r} represents a function or a function type. |
| 4464 | + |
| 4465 | +\pnum |
| 4466 | +\returns |
| 4467 | +\begin{itemize} |
| 4468 | +\item |
| 4469 | + If \tcode{r} represents a function $F$, |
| 4470 | + then a \tcode{vector} containing reflections of the parameters of $F$, |
| 4471 | + in the order in which they appear in a declaration of $F$. |
| 4472 | +\item |
| 4473 | + Otherwise, \tcode{r} represents a function type $T$; |
| 4474 | + a \tcode{vector} containing reflections of the types |
| 4475 | + in parameter-type-list\iref{dcl.fct} of $T$, |
| 4476 | + in the order in which they appear in the parameter-type-list. |
| 4477 | +\end{itemize} |
| 4478 | +\end{itemdescr} |
| 4479 | + |
| 4480 | +\indexlibraryglobal{variable_of}% |
| 4481 | +\begin{itemdecl} |
| 4482 | +consteval info variable_of(info r); |
| 4483 | +\end{itemdecl} |
| 4484 | + |
| 4485 | +\begin{itemdescr} |
| 4486 | +\pnum |
| 4487 | +\constantwhen |
| 4488 | +\begin{itemize} |
| 4489 | +\item |
| 4490 | + \tcode{r} represents a parameter of a function $F$ and |
| 4491 | +\item |
| 4492 | + there is a point $P$ in the evaluation context |
| 4493 | + for which the innermost non-block scope enclosing $P$ |
| 4494 | + is the function parameter scope\iref{basic.scope.param} |
| 4495 | + associated with $F$. |
| 4496 | +\end{itemize} |
| 4497 | + |
| 4498 | +\pnum |
| 4499 | +\returns |
| 4500 | +The reflection of the parameter variable corresponding to \tcode{r}. |
| 4501 | +\end{itemdescr} |
| 4502 | + |
| 4503 | +\indexlibraryglobal{return_type_of}% |
| 4504 | +\begin{itemdecl} |
| 4505 | +consteval info return_type_of(info r); |
| 4506 | +\end{itemdecl} |
| 4507 | + |
| 4508 | +\begin{itemdescr} |
| 4509 | +\pnum |
| 4510 | +\constantwhen |
| 4511 | +Either \tcode{r} represents a function |
| 4512 | +and \tcode{\exposid{has-type}(r)} is \tcode{true} |
| 4513 | +or \tcode{r} represents a function type. |
| 4514 | + |
| 4515 | +\pnum |
| 4516 | +\returns |
| 4517 | +The reflection of the return type |
| 4518 | +of the function or function type represented by \tcode{r}. |
| 4519 | +\end{itemdescr} |
| 4520 | + |
4328 | 4521 | \rSec2[meta.reflection.access.context]{Access control context}
|
4329 | 4522 |
|
4330 | 4523 | \pnum
|
|
0 commit comments